2 /* Prototype : array array_intersect(array $arr1, array $arr2 [, array $...])
3 * Description: Returns the entries of arr1 that have values which are present in all the other arguments
4 * Source code: ext/standard/array.c
8 * Testing array_intersect() function by passing values to $arr1 argument other than arrays
9 * and see that function emits proper warning messages wherever expected.
10 * The $arr2 argument is a fixed array.
16 public function __toString() {
17 return "Class A object";
20 <<__EntryPoint
>> function main(): void
{
21 echo "*** Testing array_intersect() : Passing non-array values to \$arr1 argument ***\n";
23 // array to be passsed to $arr2 as default argument
26 // array to be passed to optional argument
27 $arr3 = darray
[0 => 1, 1 => 2, "one" => 1, "two" => 2];
29 // get an unset variable
38 // get a resource variable
39 $fp = fopen(__FILE__
, "r");
41 // unexpected values to be passed to $arr1 argument
80 /*22*/ @$undefined_var,
89 // loop through each sub-array within $arrrays to check the behavior of array_intersect()
91 foreach($arrays as $unexpected_value) {
92 echo "\n-- Iterator $iterator --";
94 // Calling array_intersect() with default arguments
95 var_dump( array_intersect($unexpected_value,$arr2) );
97 // Calling array_intersect() with more arguments
98 var_dump( array_intersect($unexpected_value, $arr2, $arr3) );
102 // close the file resource used