1--TEST-- 2Test each() function : usage variations - Internal array pointer 3--FILE-- 4<?php 5/* Prototype : array each(array $arr) 6 * Description: Return the currently pointed key..value pair in the passed array, 7 * and advance the pointer to the next element 8 * Source code: Zend/zend_builtin_functions.c 9 */ 10 11/* 12 * Test the position of the internal array pointer after a call to each() 13 */ 14 15echo "*** Testing each() : usage variations ***\n"; 16 17$arr = array('zero', 'one', 'two', 'abc', 'xyz'); 18 19echo "\n-- Current position: --\n"; 20echo key($arr) . " => " . current($arr) . "\n"; 21 22echo "\n-- Call to each(): --\n"; 23var_dump( each($arr) ); 24 25echo "\n-- New position: --\n"; 26echo key($arr) . " => " . current($arr) . "\n"; 27 28echo "Done"; 29?> 30--EXPECTF-- 31*** Testing each() : usage variations *** 32 33-- Current position: -- 340 => zero 35 36-- Call to each(): -- 37array(4) { 38 [1]=> 39 string(4) "zero" 40 ["value"]=> 41 string(4) "zero" 42 [0]=> 43 int(0) 44 ["key"]=> 45 int(0) 46} 47 48-- New position: -- 491 => one 50Done 51