Examveda
Examveda

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] . ".";
?>

A. Sam is the brother of Bob and Jack

B. Sam is the brother of Bob and Bob)

C. Sam is the brother of Jack and Bob)

D. Error

Answer: Option B

Solution(By Examveda Team)

Simple definition of array and using it in a string. We have used $names[1] twice and hence Bob appears twice.

This Question Belongs to PHP >> Arrays

Join The Discussion

Related Questions on Arrays