PHP array each() Function6 Jan 2025 | 1 min read The each( ) function is an inbuilt function of PHP. It is used to fetch the key and value of the current element and moves the internal pointer forward. This function was introduced in PHP 4.0. SyntaxParameter
ReturnsThe each() function returns the current key and value pair from array_name. Example 1Output: Array ( [1] => OS [value] => OS [0] => 0 [key] => 0 ) Example 2Output: Array ( [1] =>sachin [value] =>sachin [0] => 0 [key] => 0 ) Example 3Output: Array ( [1] => dell [value] =>dell [0] => 0 [key] => 0 ) Example 4Output: Array ( [1] =>bengaluru [value] =>bengaluru [0] =>karnataka [key] =>karnataka ) Next TopicPhp-array-end-function |
The array_diff_assoc() function is used to compare an array against another array and returns the difference. In other words, we can say that array_diff_assoc() function compares the keys and values of two or more arrays and return an array that contains the entries from array1...
1 min read
PHP current() Function The current( ) function is an inbuilt function of PHP, and it is used to return the value of the current element in an array. This function was introduced in PHP 4.0. Syntax mixed current ( array $array ); Parameters Parameter Description Is compulsory array Specifies the array to use. compulsory Return Values The...
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 list() Function The PHP list( ) function is used to assign values to a list of variables in one operation. This function was introduced in PHP 4.0. Syntax array list ( mixed $var1 [, mixed $... ] ); Parameter Parameter Description Is compulsory Variable1 The first variable to assign a value to. compulsory Variable2... More variables...
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_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 array_change_key_case() Function It is an inbuilt function of PHP. The array_change_key_case() function returns an array with all arrays keys in lower case or upper case. Syntax array_change_key_case(array,case); Parameter Description Is compulsory array Specifies the array to use compulsory case Case to use(Upper or Lower) optional Important Note: If the second parameter is avoided then by default the...
1 min read
The array_merge_recursive( ) function is a built-in function in PHP. This function is used to merge the elements or values of two or more arrays together into a single array, the values of one are appended to the end of the ious one. This function...
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_fill_keys( ) function is a built-in function in PHP. It is used to create a new array filled with the given keys and value provided as an array to the function. It was introduced in PHP version 5.2. Syntax array array_fill_keys ( array $keys , mixed...
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