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

1.1       misho       1: --TEST--
                      2: Test array_slice() function : usage variations - referenced variables
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : array array_slice(array $input, int $offset [, int $length [, bool $preserve_keys]])
                      6:  * Description: Returns elements specified by offset and length 
                      7:  * Source code: ext/standard/array.c
                      8:  */
                      9: 
                     10: /*
                     11:  * Test array_slice() when:
                     12:  * 1. Passed an array of referenced variables
                     13:  * 2. $input argument is passed by reference
                     14:  */
                     15: 
                     16: echo "*** Testing array_slice() : usage variations ***\n";
                     17: 
                     18: $val1 = 'one';
                     19: $val2 = 'two';
                     20: $val3 = 'three';
                     21: 
                     22: echo "\n-- Array of referenced variables (\$preserve_keys = default) --\n";
                     23: $input = array(3 => &$val1, 2 => &$val2, 1 => &$val3);
                     24: var_dump(array_slice($input, 1, 2));
                     25: 
                     26: echo "-- Change \$val2 (\$preserve_keys = TRUE) --\n";
                     27: $val2 = 'hello, world';
                     28: var_dump(array_slice($input, 1, 2, true));
                     29: 
                     30: echo "Done";
                     31: ?>
                     32: 
                     33: --EXPECTF--
                     34: *** Testing array_slice() : usage variations ***
                     35: 
                     36: -- Array of referenced variables ($preserve_keys = default) --
                     37: array(2) {
                     38:   [0]=>
                     39:   &string(3) "two"
                     40:   [1]=>
                     41:   &string(5) "three"
                     42: }
                     43: -- Change $val2 ($preserve_keys = TRUE) --
                     44: array(2) {
                     45:   [2]=>
                     46:   &string(12) "hello, world"
                     47:   [1]=>
                     48:   &string(5) "three"
                     49: }
                     50: Done

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