PHP array_values() Function6 Jan 2025 | 1 min read The array_values( ) function is an inbuilt function of PHP. It is used to get an array of values from another array that may contain key-value pairs. This function was introduced in PHP 4.0. SyntaxParameters
Return ValuesThe array_values( ) function returns an array containing all the values of an array. Important note:The returned array will have numeric keys, starting at 0 and increase by 1. Example 1Output: Array ( [0] =>javatpoint [1] =>udemy [2] =>byjus ) Example 2Output: Array ( [0] => apple [1] => ball [2] => cat ) Example 3Output: Array ( [0] =>mario [1] => need for speed [2] =>igi [3] => road race ) Example 4Output: Array ( [0] =>Narendramodi [1] => 67 [2] => INDIA ) Next TopicPhp-array-walk-function |
The array_key_last( ) function is used to get the last key of an array. This function was introduced in PHP 7.3.0 Syntax mixed array_key_last ( array $array ); Parameters Parameter Description Is compulsory array Specifies the array. compulsory Return Values The array_key_last( ) function returns the last key of the array if the array is not...
1 min read
PHP rsort() Function The PHP rsort( ) function is used to sort an array in reverse order. This function introduced in PHP 4.0. Syntax bool rsort ( array &$array [, int $sort_flags = SORT_REGULAR ] ); Parameter Parameter Description Is compulsory array Specifies the array to use. compulsory Sort flags It specifies how to sort the array...
1 min read
The array_combine() function is an inbuilt function in PHP. This function is introduced in PHP 5. It is used to create an array by using one array for keys and another for its values. Syntax array_combine(array_keys,array_values); Parameter Description Is compulsory array_keys The keys of the array to be used compulsory array_values The values of the...
1 min read
The array_key_first( ) function is used to get the first key of an array. This function was introduced in PHP 7.3.0 Syntax mixed array_key_first ( array $array ); Parameters Parameter Description Is compulsory array Specifies the array. compulsory Return Values The array_key_first( ) function returns the first key of the array if the array is not...
1 min read
The array_walk( ) function is an inbuilt function of PHP. It is used to apply a user supplied function to every element of an array. This function was introduced in 4.0. Syntax bool array_walk ( array &$array , callable $callback [, mixed $userdata = NULL ] ); Parameters Parameter Description Is...
1 min read
PHP () Function The PHP ( ) function is used to advance the internal array pointer. It advances the internal array pointer one place forward before returning the element value. This function was introduced in PHP 4.0. Syntax mixed ( array &$array ); Parameter Parameter Description Is compulsory array Specifies the array to...
1 min read
PHP array diff_ukey() Function The array_diff_ukey() is an inbuilt function in PHP. The array_diff_ukey() function compares the keys of two or more arrays with a user-defined function, and returns an array that contains the entries from array1 that are not present in array2 or array3, etc. This...
2 min read
The array_splice() function is an extended version of array_slice() function. The array_splice() function removes selected elements from an array and replaces it with new elements. This function was introduced in PHP 4. Syntax arrayarray_splice ( array &$input , int $offset [, int $length = count($input) [, mixed...
1 min read
PHP natsort() Function The PHP natsort( ) function is used to sort an array using a "natural order" algorithm. The natsort( ) function implements a sort algorithm but maintains original keys and values. This function was introduced in PHP 4.0. Syntax bool natsort ( array &$array ); Parameter Parameter Description Is compulsory array Specifies...
2 min read
The array_intersect_uassoc( ) function is an inbuilt function in PHP. The array_intersect_uassoc( ) function is used to compare key and values of two or more arrays by using a user-defined comparison function and return the matches. It returns an array containing all the values of...
2 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India