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
$fruits = array (“apple”, “orange”, “banana”);
echo (next($fruits));
echo (next($fruits));
?>

What will be the output of the following PHP code?
<?php
$fruits = array (“apple”, “orange”, “banana”);
echo (next($fruits));
echo (next($fruits));
?>
a) orangebanana
b) appleorange
c) orangeorange
d) appleapple

Answer: a
Explanation: The next() function returns the value of the next element in the array. In the first ‘next($fruits)’ call, it will print orange which is next to apple and so on.

Join The Discussion