<?php
$info = array('name' => 'Alice', 'age' => 25);
echo count($info);
?
What is the purpose of the array_key_exists() function in PHP?
A). To check if a specified key exists in an array
B). To check if a specified value exists in an array
C). To retrieve all keys from an array
D). To retrieve all values from an array
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 . ' ';
}
?
A). 20 30 40 50
B). 10 20 30 40
C). 10 20 30 40
D). 10 20 30 40 50
Which PHP function is used to merge two or more arrays into a single array?
A). merge()
B). combine()
C). concat()
D). array_merge()
Which PHP function is used to extract a slice of an array?
A). splice()
B). slice()
C). extract()
D). split()
Which PHP function is used to determine the number of elements in an array?
A). size()
B). count()
C). length()
D). elements()
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 . ' ';
}
?
A). a b c 1 2 3
B). 1 2 3 a b c
C). a b c
D). 1 2 3
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 . ' ';
}
?
A). Red Green Blue Yellow Orange
B). Yellow Orange Red Green Blue
C). Green Blue Red Yellow Orange
D). Yellow Orange
What will be the output of the following PHP code?<?php
$matrix = array(
array(1, 2, 3),
array(4, 5, 6),
array(7, 8, 9)
);
echo $matrix[1][2];
?
A). 1
B). 2
C). 4
D). 6
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