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

1.1       misho       1: --TEST--
                      2: Test rsort() function : usage variations - referenced variables
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : bool rsort(array &$array_arg [, int $sort_flags])
                      6:  * Description: Sort an array in reverse order 
                      7:  * Source code: ext/standard/array.c
                      8:  */
                      9: 
                     10: /*
                     11:  * Test behaviour of rsort() when: 
                     12:  * 1. passed an array of referenced variables
                     13:  * 2. $array_arg is a reference to another array
                     14:  * 3. $array_arg is passed by reference
                     15:  */
                     16: 
                     17: echo "*** Testing rsort() : variation ***\n";
                     18: 
                     19: $value1 = 100;
                     20: $value2 = 33;
                     21: $value3 = 555;
                     22: 
                     23: // an array containing integer references 
                     24: $unsorted_numerics =  array( &$value1 , &$value2, &$value3);
                     25: 
                     26: echo "\n-- 'flag' value is defualt --\n";
                     27: $temp_array = $unsorted_numerics;
                     28: var_dump( rsort($temp_array) );
                     29: var_dump( $temp_array);
                     30: 
                     31: echo "\n-- 'flag' = SORT_REGULAR --\n";
                     32: $temp_array = &$unsorted_numerics;
                     33: var_dump( rsort($temp_array, SORT_REGULAR) );
                     34: var_dump( $temp_array);
                     35: 
                     36: echo "Done";
                     37: ?>
                     38: --EXPECTF--
                     39: *** Testing rsort() : variation ***
                     40: 
                     41: -- 'flag' value is defualt --
                     42: bool(true)
                     43: array(3) {
                     44:   [0]=>
                     45:   &int(555)
                     46:   [1]=>
                     47:   &int(100)
                     48:   [2]=>
                     49:   &int(33)
                     50: }
                     51: 
                     52: -- 'flag' = SORT_REGULAR --
                     53: bool(true)
                     54: array(3) {
                     55:   [0]=>
                     56:   &int(555)
                     57:   [1]=>
                     58:   &int(100)
                     59:   [2]=>
                     60:   &int(33)
                     61: }
                     62: Done

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