?
What will be the output of the following PHP code?
What will be the output of the following PHP code?
<?php
$names = array("Sam", "Bob", "Jack");
echo $names[0] . "is the brother of " . $names[1] . " and " . $names[1] . ".";
?>
<?php
$names = array("Sam", "Bob", "Jack");
echo $names[0] . "is the brother of " . $names[1] . " and " . $names[1] . ".";
?>
Answer & Solution
Correct Answer:
Option
B
Simple definition of array and using it in a string. We have used $names[1] twice and hence Bob appears twice.
Join the Discussion
Login to post a comment or share your explanation.
Login