Annotation of embedaddon/php/ext/standard/tests/array/reset_variation3.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test reset() function : usage variations - Referenced variables
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : mixed reset(array $array_arg)
! 6: * Description: Set array argument's internal pointer to the first element and return it
! 7: * Source code: ext/standard/array.c
! 8: */
! 9:
! 10: /*
! 11: * Reference two arrays to each other then call reset() to test position of
! 12: * internal pointer in both arrays
! 13: */
! 14:
! 15: echo "*** Testing reset() : usage variations ***\n";
! 16:
! 17: $array1 = array ('zero', 'one', 'two');
! 18:
! 19: echo "\n-- Initial position of internal pointer --\n";
! 20: var_dump(current($array1));
! 21:
! 22: // Test that when two variables are referenced to one another
! 23: // the internal pointer is the same for both
! 24: $array2 = &$array1;
! 25:
! 26: next($array1);
! 27:
! 28: echo "\n-- Position after calling next() --\n";
! 29: echo "\$array1: ";
! 30: var_dump(current($array1));
! 31: echo "\$array2: ";
! 32: var_dump(current($array2));
! 33:
! 34: echo "\n-- Position after calling reset() --\n";
! 35: var_dump(reset($array1));
! 36: echo "\$array1: ";
! 37: var_dump(current($array1));
! 38: echo "\$array2: ";
! 39: var_dump(current($array2));
! 40: ?>
! 41: ===DONE===
! 42: --EXPECTF--
! 43: *** Testing reset() : usage variations ***
! 44:
! 45: -- Initial position of internal pointer --
! 46: string(4) "zero"
! 47:
! 48: -- Position after calling next() --
! 49: $array1: string(3) "one"
! 50: $array2: string(3) "one"
! 51:
! 52: -- Position after calling reset() --
! 53: string(4) "zero"
! 54: $array1: string(4) "zero"
! 55: $array2: string(4) "zero"
! 56: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>