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
$array = array(“red”, “green”);
array_push($array, “blue”, “yellow”);
print_r($array);
?>

What will be the output of the following PHP code?
<?php
$array = array(“red”, “green”);
array_push($array, “blue”, “yellow”);
print_r($array);
?>
a) Array ( [0] => red [1] => green [2] => blue [3] => yellow )
b) Array ( [0] => blue [1] => yellow [2] => red [3] => green )
c) Array ( [0] => red [1] => green )
d) Array ( [0] => blue [1] => yellow )

Answer: a
Explanation: The function array_push() inserts one or more elements to the end of an array. So, in the above program blue and yellow will be inserted after previous values.

Join The Discussion