My Report (&Account)

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%)

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

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

Question 1 of 10 (sanfoundry.com)

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

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

Question 2 of 10 (sanfoundry.com)

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

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

Question 3 of 10 (sanfoundry.com)

4. 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));
?>

Question 4 of 10 (sanfoundry.com)

5. 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));
?>

Question 5 of 10 (sanfoundry.com)

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

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

Question 6 of 10 (sanfoundry.com)

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

Question 7 of 10 (sanfoundry.com)

8. 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);
?>

Question 8 of 10 (sanfoundry.com)

9. 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);
?>

Question 9 of 10 (sanfoundry.com)

10. 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);
?>

Question 10 of 10 (sanfoundry.com)


 

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

advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
I’m Manish - Founder and CTO at Sanfoundry. I’ve been working in tech for over 25 years, with deep focus on Linux kernel, SAN technologies, Advanced C, Full Stack and Scalable website designs.

You can connect with me on LinkedIn, watch my Youtube Masterclasses, or join my Telegram tech discussions.

If you’re in your 20s–40s and exploring new directions in your career, I also offer mentoring. Learn more here.