ExamVeda
Login
Home
This question belongs to PHP Arrays
Arrays
?

What will be the output of the following PHP code?
<?php
$a1 = array("a" => "red", "b" => "green", "c" => "blue", "d" => "yellow");
$a2 = array("e" => "red", "f" => "green", "g" => "blue", "h" => "orange");
$a3 = array("i" => "orange");
$a4 = array_combine($a2, $a3);
$result = array_diff($a4, $a2);
print_r($result);
?>

Answer & Solution
Correct Answer: Option A
The array_diff() function compares the values of two (or more) arrays, and returns the differences.
Examveda
Question posted by Examveda
Community

Join the Discussion

3 Comments
عبووود الأسطا
عبووود الأسطا 5 years ago
maybe this code will result as :
Array ( [i] => orange )
because the array_diff is not between $a4 and $a1
SK S
SK S 7 years ago
It should be $a = array_merge($a2, $a3);
array_combine() give warning if both array's parameter have not same.

many of question's answer are wrong. Please check it.
SK S
SK S 7 years ago
It should be $a = array_merge($a2, $a3);
array_combine() give warning if both array's parameter have not same.

many of question's answer are wrong. Please check it.