<?php
$arr1 = array('a', 'b', 'c');
$arr2 = array(1, 2, 3);
$result = array_merge($arr1, $arr2);
foreach ($result as $item) {
echo $item . ' ';
}
?
What will be the output of the following PHP code?<?php
$person = array('name' => 'John', 'age' => 30, 'city' => 'New York');
echo $person['age'];
?
A). name: John
B). age: 30
C). city: New York
D). John
What will be the output of the following PHP code?<?php
$numbers = array(10, 20, 30, 40, 50);
echo count($numbers);
?
A). 10
B). 20
C). 5
D). 50
What type of index do indexed arrays in PHP use?
A). String
B). Integer
C). Key-value pairs
D). Floating-point number
What is the purpose of the array_push() function in PHP?
A). To remove elements from an array
B). To add elements to the beginning of an array
C). To add elements to the end of an array
D). To reverse the order of elements in an array
Which PHP function is used to sort an array in ascending order, maintaining the key-value pairs?
A). sort()
B). ksort()
C). asort()
D). rsort()
Which PHP function is used to merge two or more arrays into a single array?
A). merge()
B). combine()
C). concat()
D). array_merge()
What is the output of the following PHP code?<?php
$colors = array('Red', 'Green', 'Blue');
echo $colors[1];
?
A). Red
B). Green
C). Blue
D). 1
Which PHP function is used to remove the last element from an array?
A). remove()
B). pop()
C). delete()
D). unset()
What is the correct way to access the first element of an indexed array in PHP?
A). $array[0]
B). $array[1]
C). $array['first']
D). $array['0']
Which PHP construct is commonly used to iterate over elements of an array?
A). foreach loop
B). while loop
C). do-while loop
D). for loop