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 |
The array_diff() function compares two or more arrays and returns an array with the keys and values from the first array, only if the value is not present in any of the other arrays. This function was introduced in PHP 4.0. Syntax array_diff(array1,array2,array3...); Parameter Description Is compulsory array1 The array to compare...
2 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
It is an inbuilt function in PHP. The array_column() function is used to return the values from a single column in the input array. This function is introduced in PHP 5.5. Syntax array_column(array,column_key,index_key); Parameter Description Is compulsory array Specifies the multi-dimensional array to use compulsory Column_key This parameter may be an integer or a string...
2 min read
PHP sort() Function The PHP sort( ) function is used to sort the array elements in ascending order. This function was introduced in PHP 4.0. Syntax bool sort ( array &$array [, int $sort_flags = SORT_REGULAR ] ); Parameter Parameter Description Is compulsory array Specifies the array to be sorted. compulsory Sort flags Sorting behavior. Possible type : SORT_REGULAR...
1 min read
PHP sizeof() Function The sizeof( ) function is an alias of count( ) function. The sizeof( ) function returns the number of elements in an array. This function was introduced in PHP 4.0. Syntax intsizeof(array, mode); Parameter Parameter Description Is compulsory array Specifies the array to use. compulsory mode Specifies the mode. Possible values: 0 - Default. Does...
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_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
The array_pop() function is inbuilt function of PHP. The array_pop() function is used to remove the last element of an array. For an empty array, this function returns NULL. This function was introduced in PHP 4.0. Syntax mixed array_pop ( array &$array ); Parameters Parameter Description Required/Optional array Specifies an array. compulsory Return Type The array_pop()...
1 min read
The array_merge( ) function is a built-in function of PHP. This function is used to merge the elements or values of two or more arrays together into a single array. This function was introduced in PHP 4.0. Syntax array array_merge(array $array1[, array $...]); Parameter Parameter Description Is compulsory array1 Specifies an array. compulsory array2 Specifies an...
1 min read
The array_intersect( ) function is used to Computes the intersection of arrays. It compares two or more arrays and returns an array containing all the values of the first array that are present in other arrays. In this operation, keys are preserved. This function was...
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