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
$a1 = array_fill(3, 4, “blue”);
$b1 = array_fill(0, 1, “red”);
print_r($a1);
echo “<br>”;
print_r($b1);
?>

What will be the output of the following PHP code?
<?php
$a1 = array_fill(3, 4, “blue”);
$b1 = array_fill(0, 1, “red”);
print_r($a1);
echo “<br>”;
print_r($b1);
?>
a) Array ( [3] => blue [4] => blue)
Array ( [0] => red )
b) Array ( [4] => blue [5] => blue [6] => blue)
Array ( [0] => red )
c) Array ( [3] => blue [4] => blue [5] => blue [6] => blue )
Array ()
d) Array ( [3] => blue [4] => blue [5] => blue [6] => blue )
Array ( [0] => red )

Answer: d
Explanation: The array_fill() function fills an array with values.

Join The Discussion