Home »
MCQs »
PHP MCQs
What will be the output of the following PHP code (23)?
95. What will be the output of the following PHP code?
<?php
$cars = array(
"BMW",
"Mercedes",
"Honda",
);
foreach ($cars as $c)
{
echo "$c ";
}
?>
- BMW Mercedes Honda
- Honda Mercedes BMW
- SyntaxError
- TypeError
Answer: A) BMW Mercedes Honda
Explanation:
The foreach loop statement is used to loop through a block of code for each element in an array. Thus, the output will be "BMW Mercedes Honda".