Q. What will be the output of the following PHP code?
Code:
<?php
$user = array("Ats ", "Ajit ", "Rahul ", "Aju ");
for ($str=0; $str < count($user); $str++) {
if ($user[$str] == "Rahul ") continue;
printf ($user[$str]);
}
?>
β
Correct Answer: (C)
Ats Ajit Aju
Explanation: When the mentioned for loop executes, it will start printing all the strings in the array. But when it sees that the if condition is true, it doesn't print the string and just skip the code below it and start with next value.
So it will print "Ats Ajit Aju " only.