My Report

PHP Array Test – 3


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. What will be the output of the following PHP code?

<?php
$number = range(0, 5);
print_r ($number);
?>

2. What will be the output of the following PHP code?

<?php
$people = array("Peter", "Susan", "Edmund", "Lucy");
echo pos($people);
?>

3. What will be the output of the following PHP code?

<?php
$a1 = array("a" => "red", "b" => "green", "c" => "blue", "d" => "yellow");
$a2 = array("e" => "red","f" => "green", "g" => "blue");
$result = array_intersect($a1, $a2);
print_r($result);
?>

4. What will be the output of the following PHP code?

<?php
$age = array("Harry" => "21", "Ron" => "19", "Malfoy" => "23");
ksort($age);
foreach($age as $x => $x_value)
{
    echo "Key=" . $x . ", Value=" . $x_value;
    echo "<br>";
}
?>

5. What will be the output of the following PHP code?

<?php
$a = array("a" => "Jaguar", "b" => "Land Rover", 
"c" => "Audi", "d" => "Maseratti");
echo array_search("Audi", $a);
?>

6. What will be the output of the following PHP code?

<?php
 $age = array("Harry" => "21", "Ron" => "23","Malfoy" => "21");
 array_pop($age);
 print_r(array_change_key_case($age, CASE_UPPER));
?>

7. What will be the output of the following PHP code?

<?php
$array = array("red", "green");
array_push($array, "blue", "yellow");
print_r($array);
?>

8. What will be the output of the following PHP code?

<?php
$a = array(12, 5, 2);
echo(array_product($a));
?>

9. What will be the output of the following PHP code?

<?php
$city_west = array("NYC", "London");
$city_east = array("Mumbai", "Beijing");
print_r(array_replace($city_west, $city_east));
?>

10. What will be the output of the following PHP code?

<?php
$a1 = array("a" => "red", "b" => "green", "c" => "blue", "d" => "yellow");
$result = array_flip($a1);
print_r($result);
?>

 

Start practicing “1000 MCQs on PHP”, and once you are ready, you can take tests on all topics by attempting our “PHP Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.