PHP Arrays
- What will be the output of the following PHP code?
<?php
$Country = array("India", "England", "USA");
echo "I like " . $Country[2] . ", " . $Country[1] . " and " . $Country[0] . ".";
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
The order of elements defined.
- What will be the output of the following PHP code?
<?php
$Student = array("Rahul", "Ajit", "Ats");
echo $Student[0] . " is the friend of " . $Student[1] . " and " . $Student[2] . ".";
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Simple definition of array and using it in a string. We have used $Student [1],$Student [1] and hence Ajit, Ats appears.
- What will be the output of the following PHP code?
<?php
$Student = array("Ajit", "Rahul", "Ats");
echo $names[0] . "is the friend of " . $names[1] . " and " . $names[1] . ".".$friend;
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
$brother undeclared.
- What will be the output of the following PHP code?
<?php
$Country = array("INDIA", "ENGLAND", "ISRAEL", "USA");
array_pop($Country);
print_r($Country);
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
The array_pop() function deletes the last element of an array.
- What will be the output of the following PHP code ?
<?php
$num = array(2, 15, 20, 1);
echo(array_product($num));
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
The array_product() function calculates and returns the product of an array.