import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-array / in_array_variation3.php
blob70836dda98c198c48caeba050e19c6a28575c87b
1 <?php
2 /*
3 * Prototype : bool in_array ( mixed $needle, array $haystack [, bool $strict] )
4 * Description: Searches haystack for needle and returns TRUE
5 * if it is found in the array, FALSE otherwise.
6 * Source Code: ext/standard/array.c
7 */
9 /* Test in_array() with haystack as sub-array and object */
11 /* checking for sub-arrays with in_array() */
12 echo "*** Testing sub-arrays with in_array() ***\n";
13 $sub_array = array (
14 "one",
15 array(1, 2 => "two", "three" => 3),
16 4 => "four",
17 "five" => 5,
18 array('', 'i')
20 var_dump( in_array("four", $sub_array) );
21 //checking for element in a sub-array
22 var_dump( in_array(3, $sub_array[1]) );
23 var_dump( in_array(array('','i'), $sub_array) );
25 /* checking for objects in in_array() */
26 echo "\n*** Testing objects with in_array() ***\n";
27 class in_array_check {
28 public $array_var = array(1=>"one", "two"=>2, 3=>3);
29 public function foo() {
30 echo "Public function\n";
34 $in_array_obj = new in_array_check(); //creating new object
35 //error: as wrong datatype for second argument
36 var_dump( in_array("array_var", $in_array_obj) );
37 //error: as wrong datatype for second argument
38 var_dump( in_array("foo", $in_array_obj) );
39 //element found as "one" exists in array $array_var
40 var_dump( in_array("one", $in_array_obj->array_var) );
42 echo "Done\n";