Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following PHP code?
<?php
$city_west = array(“NYC”, “London”);
$city_east = array(“Mumbai”, “Beijing”);
print_r(array_replace($city_west, $city_east));
?>

What will be the output of the following PHP code?
<?php
$city_west = array(“NYC”, “London”);
$city_east = array(“Mumbai”, “Beijing”);
print_r(array_replace($city_west, $city_east));
?>
a) Array ( [1] => Mumbai [0] => Beijing )
b) Array ( [0] => NYC [1] => London )
c) Array ( [1] => NYC [0] => London )
d) Array ( [0] => Mumbai [1] => Beijing )

Answer: d
Explanation: The function array_replace() replaces the values of the first array with the values from following arrays. So, in the above program the values of city_west will be replaced with city_east.

Join The Discussion