Annotation of embedaddon/php/ext/standard/tests/array/array_key_exists_variation5.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test array_key_exists() function : usage variations - multidimensional arrays
3: --FILE--
4: <?php
5: /* Prototype : bool array_key_exists(mixed $key, array $search)
6: * Description: Checks if the given key or index exists in the array
7: * Source code: ext/standard/array.c
8: * Alias to functions: key_exists
9: */
10:
11: /*
12: * Test how array_key_exists() behaves with multi-dimensional arrays
13: */
14:
15: echo "*** Testing array_key_exists() : usage variations ***\n";
16:
17: $multi_array = array ('zero' => 'val1',
18: 'one' => 'val2',
19: 'sub1' => array (1, 2, 3));
20:
21: echo "\n-- Attempt to match key in sub-array --\n";
22: // this key is in the sub-array
23: var_dump(array_key_exists(0, $multi_array));
24:
25: echo "\n-- \$search arg points to sub-array --\n";
26: var_dump(array_key_exists(0, $multi_array['sub1']));
27:
28: echo "Done";
29: ?>
30:
31: --EXPECTF--
32: *** Testing array_key_exists() : usage variations ***
33:
34: -- Attempt to match key in sub-array --
35: bool(false)
36:
37: -- $search arg points to sub-array --
38: bool(true)
39: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>