PHP array_reverse() Function6 Jan 2025 | 2 min read The array_reverse() function is a inbuilt function of PHP. The array_reverse( ) function is used to reverse the order of the elements in an array. This function was introduced in PHP 4.0. SyntaxParameter
Return typeThe array_reverse() function returns the reversed array. Example 1Output: Array ( [0] => javatpoint [1] => 2 [2] => Array ( [0] => PHP [1] => JAVA ) ) Array ( [0] => Array ( [0] => PHP [1] => JAVA ) [1] => 2 [2] => javatpoint ) Array ( [2] => Array ( [0] => PHP [1] => JAVA ) [1] => 2 [0] => javatpoint ) Example 2Output: Array ([4] => 500 [3] => 400 [2] => 300 [1] => 200 [0] => 100) Array ([0] => 500 [1] => 400 [2] => 300 [3] => 200 [4] => 100) Example 3Output: Array ( [c] => PYTHON [b] => JAVA [a] => PHP ) Example 4Output: Array ( [0] => PHP [1] => JAVA [2] => PERL [3] => PYTHON ) Array ( [3] => PYTHON [2] => PERL [1] => JAVA [0] => PHP ) Next TopicPhp-array-rsort-function |
PHP uksort() Function The PHP uksort( ) function is used to sort an array by the elements keys using a user-defined comparison function. This function was introduced in PHP 4.0. Syntax bool uksort ( array &$array , callable $key_compare_func ); Parameter Parameter Description Is compulsory array Specifies the array to be sorted. compulsory user_defined_function This function is...
2 min read
The array_uintersect() is an inbuilt function in PHP. It is used to compute the intersection of two or more arrays depending on the values. The first array values are compared with all the other arrays with the help of an user-defined function, and the matches...
1 min read
The in_array( ) function is an inbuilt function of PHP. It is used to search an array for a specific value. If the third parameter strict is set to true, the in_array( ) function will also check the types of the $values. Syntax bool in_array ( mixed...
1 min read
PHP usort( ) Function The PHP usort( ) function is used to sort an array by its value using a user-supplied comparison function. If the array you wish to sort needs to be sorted by some non-trivial criteria, you should use this function. This function was...
2 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. Syntax array array_values ( array $array ); Parameters Parameter Description Is compulsory array Specifying an array. compulsory Return Values The array_values( )...
1 min read
The array_unshift( ) function is an inbuilt function of PHP. It is used to add one or more elements to the beginning of an array. This function was introduced in PHP 4.0. Syntax int array_unshift ( array &$array [, mixed $... ] ); Parameters Parameter Description Is compulsory array The input array. compulsory List of...
1 min read
The array_intersect_ukey( ) function Computes the intersection of arrays using a callback function on the keys for comparison. The function returns an array containing all the values of the first array which have matching keys that are present in all the arguments. This function was...
1 min read
The array_intersect_key( ) function computes the intersection of arrays using keys for comparison. This function compares the keys of two or more arrays and returns the matches. This function compares the keys of two or more arrays and returns an array that contains the entries...
1 min read
PHP krsort() Function The PHP krsort( ) function is used to sort the array elements by the key in descending order. It is mainly used in the associative array. This function was introduced in PHP 4.0. Syntax bool krsort ( array &$array [, int $sort_flags = SORT_REGULAR ]...
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
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