Examveda
Examveda

What will be the output of the following PHP code ?
<?php
$a = array("hi", "hello", "bye");
foreach ($a as $value) 
{
    if (count($a) == 2)
    print $value;         
}
?>

A. hihellobye

B. infinite loop

C. hihello

D. no output

Answer: Option D

Solution(By Examveda Team)

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

This Question Belongs to PHP >> Control Structures(Loop In PHP)

Join The Discussion

Related Questions on Control Structures(Loop in PHP)