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