Annotation of embedaddon/php/ext/standard/tests/array/extract_variation4.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test extract() function (variation 4) 
                      3: --FILE--
                      4: <?php
                      5: 
                      6: $mixed_array = array(
                      7:   array( 1 => "one", 2 => "two", 3 => 7, 4 => "four", 5 => "five" ),
                      8:   array( "f" => "fff", "1" => "one", 4 => 6, "" => "blank", 2.4 => "float", "F" => "FFF",
                      9:          "blank" => "", 3.7 => 3.7, 5.4 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL, NULL => 3 ),
                     10:   array( 12, "name", 'age', '45' ),
                     11: );
                     12: 
                     13: $counter = 0;
                     14: 
                     15: foreach ( $mixed_array as $sub_array ) {
                     16:   echo "\n-- Iteration $counter --\n";
                     17:   $counter++;
                     18: 
                     19:   var_dump ( extract($sub_array)); /* Single Argument */
                     20: 
                     21:   /* variations of two arguments */
                     22:   var_dump ( extract($sub_array, EXTR_OVERWRITE));
                     23:   var_dump ( extract($sub_array, EXTR_SKIP));
                     24:   var_dump ( extract($sub_array, EXTR_IF_EXISTS));
                     25: 
                     26:   /* variations of three arguments with use of various extract types*/
                     27:   var_dump ( extract($sub_array, EXTR_PREFIX_INVALID, "ssd"));
                     28:   var_dump ( extract($sub_array, EXTR_PREFIX_SAME, "sss"));
                     29:   var_dump ( extract($sub_array, EXTR_PREFIX_ALL, "bb"));
                     30:   var_dump ( extract($sub_array, EXTR_PREFIX_ALL, ""));  // "_" taken as default prefix 
                     31:   var_dump ( extract($sub_array, EXTR_PREFIX_IF_EXISTS, "bb"));
                     32: }
                     33: 
                     34: echo "Done\n";
                     35: ?>
                     36: --EXPECTF--
                     37: -- Iteration 0 --
                     38: int(0)
                     39: int(0)
                     40: int(0)
                     41: int(0)
                     42: int(5)
                     43: int(0)
                     44: int(5)
                     45: int(5)
                     46: int(0)
                     47: 
                     48: -- Iteration 1 --
                     49: int(4)
                     50: int(4)
                     51: int(0)
                     52: int(4)
                     53: int(12)
                     54: int(4)
                     55: int(11)
                     56: int(11)
                     57: int(4)
                     58: 
                     59: -- Iteration 2 --
                     60: int(0)
                     61: int(0)
                     62: int(0)
                     63: int(0)
                     64: int(4)
                     65: int(0)
                     66: int(4)
                     67: int(4)
                     68: int(0)
                     69: Done

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