Home » PHP » PHP For Loops » Question
  1. What will be the output of the following PHP code ?
    <?php
    $arr = array("Hello", "Interview", "Mania");
    foreach ($arr as $val)
    {
    if (count($arr) == 2)
    print $val;
    }
    ?>
    1. Nothing
    2. Error
    3. HelloInterviewMania
    4. InterviewHelloMania
    5. None of these
Correct Option: D

As count($arr) returns 3 the condition is always false.



Your comments will be displayed only after manual approval.