PHP each() Function

The each() function returns the current element key and value, and moves the internal pointer forward.

Note: After each() has executed, the array cursor will be left on the next element of the array, or past the last element if it hits the end of the array. You have to use reset() if you want to traverse the array again using each.

Parameter Description
array Required. Specifies the array to use

Syntax

each(array) 

Example

$names=array("Samuel","Lachlan","Alex");
print_r(each($names));

Output

Array ( [1] => Samuel [value] => Samuel [0] => 0 [key] => 0 ) 

Leave a Reply

Your email address will not be published. Required fields are marked *