1--TEST-- 2Test each() function : basic functionality 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 basic functionality of each() 13 */ 14 15echo "*** Testing each() : basic functionality ***\n"; 16 17$arr = array ('one' => 1, 'zero', 'two' => 'deux', 20 => 'twenty'); 18echo "\n-- Passed array: --\n"; 19var_dump($arr); 20 21echo "\n-- Initial position: --\n"; 22var_dump(each($arr)); 23 24echo "\n-- End position: --\n"; 25end($arr); 26var_dump(each($arr)); 27 28echo "\n-- Passed the end of array: --\n"; 29var_dump(each($arr)); 30 31echo "Done"; 32?> 33--EXPECTF-- 34*** Testing each() : basic functionality *** 35 36-- Passed array: -- 37array(4) { 38 ["one"]=> 39 int(1) 40 [0]=> 41 string(4) "zero" 42 ["two"]=> 43 string(4) "deux" 44 [20]=> 45 string(6) "twenty" 46} 47 48-- Initial position: -- 49array(4) { 50 [1]=> 51 int(1) 52 ["value"]=> 53 int(1) 54 [0]=> 55 string(3) "one" 56 ["key"]=> 57 string(3) "one" 58} 59 60-- End position: -- 61array(4) { 62 [1]=> 63 string(6) "twenty" 64 ["value"]=> 65 string(6) "twenty" 66 [0]=> 67 int(20) 68 ["key"]=> 69 int(20) 70} 71 72-- Passed the end of array: -- 73bool(false) 74Done