1--TEST--
2Test in_array() function : usage variations - haystack as resource/multi dimensional array
3--FILE--
4<?php
5/* Test in_array() with haystack as resource and multidimensional arrays */
6
7/* checking for Resources */
8echo "*** Testing resource type with in_array() ***\n";
9//file type resource
10$file_handle = fopen(__FILE__, "r");
11
12//directory type resource
13$dir_handle = opendir( __DIR__ );
14
15//store resources in array for comparison.
16$resources = array($file_handle, $dir_handle);
17
18// search for resource type in the resource array
19var_dump( in_array($file_handle, $resources, true) );
20//checking for (int) type resource
21var_dump( in_array((int)$dir_handle, $resources, true) );
22
23/* Miscellenous input check  */
24echo "\n*** Testing miscelleneos inputs with in_array() ***\n";
25//matching "Good" in array(0,"hello"), result:true in loose type check
26var_dump( in_array("Good", array(0,"hello")) );
27//false in strict mode
28var_dump( in_array("Good", array(0,"hello"), TRUE) );
29
30//matching integer 0 in array("this"), result:true in loose type check
31var_dump( in_array(0, array("this")) );
32// false in strict mode
33var_dump( in_array(0, array("this")),TRUE );
34
35//matching string "this" in array(0), result:true in loose type check
36var_dump( in_array("this", array(0)) );
37// false in stric mode
38var_dump( in_array("this", array(0), TRUE) );
39
40//checking for type FALSE in multidimensional array with loose checking, result:false in loose type check
41var_dump( in_array(FALSE,
42                   array("a"=> TRUE, "b"=> TRUE,
43                         array("c"=> TRUE, "d"=>TRUE)
44                        )
45                  )
46        );
47
48//matching string having integer in beginning, result:true in loose type check
49var_dump( in_array('123abc', array(123)) );
50var_dump( in_array('123abc', array(123), TRUE) ); // false in strict mode
51
52echo "Done\n";
53?>
54--EXPECT--
55*** Testing resource type with in_array() ***
56bool(true)
57bool(false)
58
59*** Testing miscelleneos inputs with in_array() ***
60bool(false)
61bool(false)
62bool(false)
63bool(false)
64bool(true)
65bool(false)
66bool(false)
67bool(false)
68bool(false)
69bool(false)
70Done
71