N

Neha Sharma • 6.85K Points
Tutor III

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]); 
}
?>
  • (A) Error
  • (B) Rahul
  • (C) Ats Ajit Aju
  • (D) Ats Ajit Rahul Aju
  • Correct Answer - Option(C)
  • Views: 112
  • Filed under category PHP

Explanation by: Mr. Dubey
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.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.


Question analytics