Return to each_basic.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / array |
1.1 misho 1: --TEST-- 2: Test 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: 15: echo "*** Testing each() : basic functionality ***\n"; 16: 17: $arr = array ('one' => 1, 'zero', 'two' => 'deux', 20 => 'twenty'); 18: echo "\n-- Passed array: --\n"; 19: var_dump($arr); 20: 21: echo "\n-- Initial position: --\n"; 22: var_dump(each($arr)); 23: 24: echo "\n-- End position: --\n"; 25: end($arr); 26: var_dump(each($arr)); 27: 28: echo "\n-- Passed the end of array: --\n"; 29: var_dump(each($arr)); 30: 31: echo "Done"; 32: ?> 33: --EXPECTF-- 34: *** Testing each() : basic functionality *** 35: 36: -- Passed array: -- 37: array(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: -- 49: array(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: -- 61: array(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: -- 73: bool(false) 74: Done