1--TEST-- 2Test extract() function (variation 3) 3--FILE-- 4<?php 5 6/* various combinations of arrays to be used for the test */ 7$mixed_array = array( 8 array( 6, "six", 7, "seven", 8, "eight", 9, "nine" ), 9 array( "a" => "aaa", "A" => "AAA", "c" => "ccc", "d" => "ddd", "e" => "eee" ), 10 array( "1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "five" ), 11); 12 13$counter = 0; 14 15foreach ( $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 34echo "Done\n"; 35?> 36--EXPECT-- 37-- Iteration 0 -- 38int(0) 39int(0) 40int(0) 41int(0) 42int(8) 43int(0) 44int(8) 45int(8) 46int(0) 47 48-- Iteration 1 -- 49int(5) 50int(5) 51int(0) 52int(5) 53int(5) 54int(5) 55int(5) 56int(5) 57int(5) 58 59-- Iteration 2 -- 60int(0) 61int(0) 62int(0) 63int(0) 64int(5) 65int(0) 66int(5) 67int(5) 68int(0) 69Done 70