import zend standard tests
[hiphop-php.git] / hphp / test / zend / good / ext-standard-array / array_search_variation1.php
blob991e1cb8bd553909df54acdfc84cc46445f8d605
1 <?php
2 /*
3 * Prototype : mixed array_search ( mixed $needle, array $haystack [, bool $strict] )
4 * Description: Searches haystack for needle and returns the key if it is found in the array, FALSE otherwise
5 * Source Code: ext/standard/array.c
6 */
8 /* Test array_search() with different possible needle values */
10 echo "*** Testing array_search() with different needle values ***\n";
11 $arrays = array (
12 array(0),
13 array("a" => "A", 2 => "B", "C" => 3, 4 => 4, "one" => 1, "" => NULL, "b", "ab", "abcd"),
14 array(4, array(1, 2 => 3), "one" => 1, "5" => 5 ),
15 array(-1, -2, -3, -4, -2.989888, "-0.005" => "neg0.005", 2.0 => "float2", "-.9" => -.9),
16 array(TRUE, FALSE),
17 array("", array()),
18 array("abcd\x00abcd\x00abcd"),
19 array("abcd\tabcd\nabcd\rabcd\0abcdefghij")
22 $array_compare = array (
24 "4",
25 4.00,
26 "b",
27 "5",
28 -2,
29 -2.0,
30 -2.98989,
31 "-.9",
32 "True",
33 "",
34 array(),
35 NULL,
36 "ab",
37 "abcd",
38 0.0,
39 -0,
40 "abcd\x00abcd\x00abcd"
42 /* loop to check if elements in $array_compare exist in $arrays
43 using array_search() */
44 $counter = 1;
45 foreach($arrays as $array) {
46 foreach($array_compare as $compare) {
47 echo "-- Iteration $counter --\n";
48 //strict option OFF
49 var_dump(array_search($compare,$array));
50 //strict option ON
51 var_dump(array_search($compare,$array,TRUE));
52 //strict option OFF
53 var_dump(array_search($compare,$array,FALSE));
54 $counter++;
58 echo "Done\n";