PHP Array each() Function

What is each() Function?

Explanation

The "each()" function returns the current key and value pair from an array and advance the array cursor.

Syntax:


each(array)

In the above syntax "array" is the array from which the current key, value pair is returned and the cursor moves to the next element.

Example :


<?php
$b=array("Grapes","Apple","Cherry");
print_r (each($b));
?>
Result :

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

In the above example the current element key and value from the array "$b" is displayed and the cursor moves to the next element.

PHP Topics


Ask Questions

Ask Question