1--TEST--
2Test array_search() function : usage variations - different haystack values
3--FILE--
4<?php
5/* Test array_search() with different possible haystack values */
6
7echo "*** Testing array_search() with different haystack values ***\n";
8
9$misc_array = array (
10  'a',
11  'key' =>'d',
12  3,
13  ".001" =>-67,
14  "-.051" =>"k",
15  0 =>"-.08",
16  "e" =>"5",
17  "y" =>NULL,
18  NULL =>"",
19  0,
20  TRUE,
21  FALSE,
22  -27.39999999999,
23  " ",
24  "abcd\x00abcd\x00\abcd\x00abcdefghij",
25  "abcd\nabcd\tabcd\rabcd\0abcd"
26);
27$array_type = array(TRUE, FALSE, 1, 0, -1, "1", "0", "-1", NULL, array(), "PHP", "");
28/* loop to do loose and strict type check of elements in
29   $array_type on elements in $misc_array using array_search();
30   checking PHP type comparison tables
31*/
32$counter = 1;
33foreach($array_type as $type) {
34  echo "-- Iteration $counter --\n";
35  //loose type checking
36  var_dump( array_search($type,$misc_array ) );
37  //strict type checking
38  var_dump( array_search($type,$misc_array,true) );
39  //loose type checking
40  var_dump( array_search($type,$misc_array,false) );
41  $counter++;
42}
43
44echo "Done\n";
45?>
46--EXPECT--
47*** Testing array_search() with different haystack values ***
48-- Iteration 1 --
49int(0)
50int(3)
51int(0)
52-- Iteration 2 --
53string(1) "y"
54int(4)
55string(1) "y"
56-- Iteration 3 --
57int(3)
58bool(false)
59int(3)
60-- Iteration 4 --
61string(1) "y"
62int(2)
63string(1) "y"
64-- Iteration 5 --
65int(3)
66bool(false)
67int(3)
68-- Iteration 6 --
69int(3)
70bool(false)
71int(3)
72-- Iteration 7 --
73int(2)
74bool(false)
75int(2)
76-- Iteration 8 --
77int(3)
78bool(false)
79int(3)
80-- Iteration 9 --
81string(1) "y"
82string(1) "y"
83string(1) "y"
84-- Iteration 10 --
85string(1) "y"
86bool(false)
87string(1) "y"
88-- Iteration 11 --
89int(3)
90bool(false)
91int(3)
92-- Iteration 12 --
93string(1) "y"
94string(0) ""
95string(1) "y"
96Done
97