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 ";
}
?>
  1. BMW Mercedes Honda
  2. Honda Mercedes BMW
  3. SyntaxError
  4. 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".

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.