-
What will be the output of the following PHP code?
<?php
$City1 = array ("Noida", "Delhi", "Chennai", "Greenville", "Branford");
$City2 = array ("Chennai", "Derby", "Enfield", "Delhi", "Greenville");
$inter = array_intersect ($City1, $City2);
print_r ($inter);
?>
-
-
Array
(
[1] => Delhi
[2] => Chennai
[3] => Greenville
[4] => Branford
) -
Array
(
[2] => Chennai
[3] => Greenville
) -
Array
(
[1] => Delhi
[2] => Noida
[3] => Chennai
[4] => Greenville
) -
Array
(
[1] => Delhi
[2] => Chennai
[3] => Greenville
) - None of these
-
Correct Option: D
The array_intersect() function returns a key preserved array consisting only of those values present in the first array that are also present in each of the other input arrays.