πŸ“Š PHP
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
πŸ’¬ Discuss
βœ… 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.

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.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
162
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Neha Sharma
Publisher
πŸ“ˆ
98%
Success Rate