Annotation of embedaddon/php/ext/standard/tests/array/each_variation4.phpt, revision 1.1.1.2

1.1       misho       1: --TEST--
                      2: Test each() function : usage variations - Referenced variables
                      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 behaviour of each() when:
                     13:  * 1. Passed an array made up of referenced variables
                     14:  * 2. Passed an array as $arr argument by reference
                     15:  */
                     16: 
                     17: echo "*** Testing each() : usage variations ***\n";
                     18: 
                     19: echo "\n-- Array made up of referenced variables: --\n";
                     20: $val1 = 'foo';
                     21: $val2 = 'bar';
                     22: 
                     23: $arr1 = array('one' => &$val1, &$val2);
                     24: 
                     25: echo "-- Call each until at the end of the array: --\n";
                     26: var_dump( each($arr1) );
                     27: var_dump( each($arr1) );
                     28: var_dump( each($arr1) );
                     29: 
                     30: echo "Done";
                     31: ?>
                     32: 
                     33: --EXPECTF--
                     34: *** Testing each() : usage variations ***
                     35: 
                     36: -- Array made up of referenced variables: --
                     37: -- Call each until at the end of the array: --
                     38: array(4) {
                     39:   [1]=>
                     40:   string(3) "foo"
                     41:   ["value"]=>
                     42:   string(3) "foo"
                     43:   [0]=>
                     44:   string(3) "one"
                     45:   ["key"]=>
                     46:   string(3) "one"
                     47: }
                     48: array(4) {
                     49:   [1]=>
                     50:   string(3) "bar"
                     51:   ["value"]=>
                     52:   string(3) "bar"
                     53:   [0]=>
                     54:   int(0)
                     55:   ["key"]=>
                     56:   int(0)
                     57: }
                     58: bool(false)
                     59: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>