11.
What will be the output of the following PHP code?
<?php
$colors = array("Red", "Green", "Blue");
array_push($colors, "Yellow", "Orange");
foreach ($colors as $color) {
echo $color . " ";
}
?
12.
Which PHP function is used to remove the last element from an array?
13.
What will be the output of the following PHP code?
<?php
$numbers = array(10, 20, 30, 40, 50);
array_pop($numbers);
foreach ($numbers as $number) {
echo $number . " ";
}
?
14.
Which PHP function is used to merge two or more arrays into a single array?
15.
What will be the output of the following PHP code?
<?php
$arr1 = array("a", "b", "c");
$arr2 = array(1, 2, 3);
$result = array_merge($arr1, $arr2);
foreach ($result as $item) {
echo $item . " ";
}
?
16.
What is the correct way to access the first element of an indexed array in PHP?
17.
What will be the output of the following PHP code?
<?php
$info = array("name" => "Alice", "age" => 25);
echo count($info);
?
18.
Which PHP function is used to extract a slice of an array?
19.
What will be the output of the following PHP code?
<?php
$arr = array(10, 20, 30, 40, 50);
$slice = array_slice($arr, 2);
foreach ($slice as $item) {
echo $item . " ";
}
?
20.
Which PHP function is used to sort an array in ascending order, maintaining the key-value pairs?