adplus-dvertising

Welcome to the Arrays and Functions in PHP MCQs Page

Dive deep into the fascinating world of Arrays and Functions in PHP with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Arrays and Functions in PHP, a crucial aspect of PHP. In this section, you will encounter a diverse range of MCQs that cover various aspects of Arrays and Functions in PHP, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within PHP.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Arrays and Functions in PHP. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of PHP.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Arrays and Functions in PHP. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Arrays and Functions in PHP MCQs | Page 11 of 15

Q101.
What will be the output of the following PHP code?
<?php
$a1 = array_fill(1, 4, "hello");
$b1 = array_fill(5, 1, "php");
$a2 = array_merge($a1, $a2);
print_r($a2);
echo "<br>";
print_r($b1);
?>
Discuss
Answer: (c).Array ( [1] => hello [2] => hello [3] => hello [4] => hello [5] => php )
Q102.
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] . ".";
?>
Discuss
Answer: (c).Sam is the brother of Jack and Bob
Q103.
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] . ".".$brother;
?>
Discuss
Answer: (d).Error
Q104.
What will be the output of the following PHP code?
<?php
$place = array("NYC", "LA", "Paris");
array_pop($place);
$place1 = array("Paris");
$place = array_merge($place, $place1);
print_r($place);
?>
Discuss
Answer: (a).Array ( [0] => LA [1] => Paris [2] => Paris )
Q105.
What will be the output of the following PHP code ?
<?php
$age = array("Harry" => "21", "Ron" => "23","Malfoy" => "21");
array_change_key_case($age, CASE_UPPER);
array_pop($age);
print_r($age);
?>
Discuss
Answer: (c).Array ( [HARRY] => 21 [RON] => 23 )
Q106.
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);
?>
Discuss
Answer: (c).Array ( [red] => a [green] => b [blue] => c [yellow] => d )
Q107.
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);
?>
Discuss
Answer: (a).Array ( [a] => red [b] => green [c] => blue )
Q108.
What will be the output of the following PHP code ?
<?php
$a = array(12, 5, 2);
echo(array_product($a));
?>
Discuss
Answer: (b).120
Q109.
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);
?>

a.

a

b.

b

c.

c

d.

d

Discuss
Answer: (c).c
Q110.
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));
?>
Discuss
Answer: (d).Array ( [0] => Mumbai [1] => Beijing )

Suggested Topics

Are you eager to expand your knowledge beyond PHP? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!