each() function returns the current key and value pair from the array.
Note − As of PHP 7.2.0, this function is deprecated and should be avoided.
each(arr)
arr - The specified array
each() function returns the key and value of the current element. This will be returned as an array with four elements, including:
two elements (1 and value) for the element value, and
Two elements (0 and key) are used for element keys.
The following is an example -
Demonstration
<?php $prod = array("Electronics", "Footwear", "Toys"); print_r (each($prod)); ?>
Array ( [1] => Electronics [value] => Electronics [0] => 0 [key] => 0 )
The above is the detailed content of each() function in PHP. For more information, please follow other related articles on the PHP Chinese website!