Annotation of embedaddon/php/ext/standard/tests/array/extract_variation2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test extract() function (variation 2)
3: --FILE--
4: <?php
5:
6: /* various combinations of arrays to be used for the test */
7: $mixed_array = array(
8: array(),
9: array( 1,2,3,4,5,6,7,8,9 ),
10: array( "One", "Two", "Three", "Four", "Five" ),
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(0)
43: int(0)
44: int(0)
45: int(0)
46: int(0)
47:
48: -- Iteration 1 --
49: int(0)
50: int(0)
51: int(0)
52: int(0)
53: int(9)
54: int(0)
55: int(9)
56: int(9)
57: int(0)
58:
59: -- Iteration 2 --
60: int(0)
61: int(0)
62: int(0)
63: int(0)
64: int(5)
65: int(0)
66: int(5)
67: int(5)
68: int(0)
69: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>