1--TEST--
2Test 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
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(5)
43int(0)
44int(5)
45int(5)
46int(0)
47
48-- Iteration 1 --
49int(4)
50int(4)
51int(0)
52int(4)
53int(12)
54int(4)
55int(11)
56int(11)
57int(4)
58
59-- Iteration 2 --
60int(0)
61int(0)
62int(0)
63int(0)
64int(4)
65int(0)
66int(4)
67int(4)
68int(0)
69Done
70