Annotation of embedaddon/php/ext/standard/tests/array/extract_variation5.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test extract() function (variation 5)
3: --FILE--
4: <?php
5:
6: $mixed_array = array(
7: array( array("oNe", "tWo", 4), array(10, 20, 30, 40, 50), array() ),
8: array( "one" => 1, "one" => 2, "three" => 3, 3, 4, 3 => 33, 4 => 44, 5, 6,
9: 5.4 => 54, 5.7 => 57, "5.4" => 554, "5.7" => 557 )
10: );
11:
12: $counter = 0;
13:
14: foreach ( $mixed_array as $sub_array ) {
15: echo "\n-- Iteration $counter --\n";
16: $counter++;
17:
18: var_dump ( extract($sub_array)); /* Single Argument */
19:
20: /* variations of two arguments */
21: var_dump ( extract($sub_array, EXTR_OVERWRITE));
22: var_dump ( extract($sub_array, EXTR_SKIP));
23: var_dump ( extract($sub_array, EXTR_IF_EXISTS));
24:
25: /* variations of three arguments with use of various extract types*/
26: var_dump ( extract($sub_array, EXTR_PREFIX_INVALID, "ssd"));
27: var_dump ( extract($sub_array, EXTR_PREFIX_SAME, "sss"));
28: var_dump ( extract($sub_array, EXTR_PREFIX_ALL, "bb"));
29: var_dump ( extract($sub_array, EXTR_PREFIX_ALL, "")); // "_" taken as default prefix
30: var_dump ( extract($sub_array, EXTR_PREFIX_IF_EXISTS, "bb"));
31: }
32:
33: echo "Done\n";
34: ?>
35: --EXPECTF--
36: -- Iteration 0 --
37: int(0)
38: int(0)
39: int(0)
40: int(0)
41: int(3)
42: int(0)
43: int(3)
44: int(3)
45: int(0)
46:
47: -- Iteration 1 --
48: int(2)
49: int(2)
50: int(0)
51: int(2)
52: int(8)
53: int(2)
54: int(8)
55: int(8)
56: int(2)
57: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>