PHP each() function
This is used to return the current key value pair of an array and move the internal pointer to the next element.
Syntax
each($array);
$array is the required parameter.
Example
<?php
$arr = array('1'=>'car' , '2'=> 'bus', '3'=>'train', '4'=> 'cycle');
$current_element = each($arr);
echo '<pre>';print_r($current_element);
$nxt_element = each($arr);
echo '<pre>'; print_r($nxt_element);
?>
Output
Array ( [1] => car [value] => car [0] => 1 [key] => 1 )Array ( [1] => bus [value] => bus [0] => 2 [key] => 2 )
Related PHP Functions
PHP array_reverse() functionPHP array_diff() function
PHP array_key_exists() function
PHP array_push() function
PHP array_search() function
PHP class_exists() function
PHP curl_setopt() function
PHP die() function
PHP dirname() function
PHP each() function
PHP explode() function
PHP file_exists() function
PHP function_exists() function
PHP getenv() function
PHP is_readable() function
PHP ksort() function
PHP mkdir() function
PHP ob_start() function
PHP parse_url() function
PHP str_repeat() function
PHP substr() function