Annotation of embedaddon/php/ext/standard/tests/array/each_variation6.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test 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:
! 15: echo "*** Testing each() : usage variations ***\n";
! 16:
! 17: $arr = array('zero', 'one', 'two', 'abc', 'xyz');
! 18:
! 19: echo "\n-- Current position: --\n";
! 20: echo key($arr) . " => " . current($arr) . "\n";
! 21:
! 22: echo "\n-- Call to each(): --\n";
! 23: var_dump( each($arr) );
! 24:
! 25: echo "\n-- New position: --\n";
! 26: echo key($arr) . " => " . current($arr) . "\n";
! 27:
! 28: echo "Done";
! 29: ?>
! 30:
! 31: --EXPECTF--
! 32: *** Testing each() : usage variations ***
! 33:
! 34: -- Current position: --
! 35: 0 => zero
! 36:
! 37: -- Call to each(): --
! 38: array(4) {
! 39: [1]=>
! 40: string(4) "zero"
! 41: ["value"]=>
! 42: string(4) "zero"
! 43: [0]=>
! 44: int(0)
! 45: ["key"]=>
! 46: int(0)
! 47: }
! 48:
! 49: -- New position: --
! 50: 1 => one
! 51: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>