PHP array Quiz Practice Set

Updated on ... 08th March 2024

Que: (1). What function is used to create an array in PHP?

A.
B.
C.
D.

Que: (2). How do you access the third element of an indexed array named $numbers in PHP?

A.
B.
C.
D.

Que: (3). What function is used to add an element to the end of an array in PHP?

A.
B.
C.
D.

Que: (4). How do you check if a key exists in an associative array in PHP?

A.
B.
C.
D.

Que: (5). What is the correct way to remove an element from an indexed array in PHP?

A.
B.
C.
D.

Que: (6). Which of the following loops is commonly used to iterate over array elements in PHP?

A.
B.
C.
D.

Que: (7). What is the output of the following code snippet?

                            $array = [1, 2, 3];
echo count($array);
                        
A.
B.
C.
D.

Que: (8). Which of the following functions is used to merge two or more arrays in PHP?

A.
B.
C.
D.

Que: (9). What is the correct way to sort an array in ascending order in PHP?

A.
B.
C.
D.

Que: (10). Which of the following functions is used to extract a slice of an array in PHP?

A.
B.
C.
D.

Que: (11). What is the output of the following PHP code snippet?

                            $array = [1, 2, 3, 4, 5];
$removed = array_pop($array);
echo $removed;
                        
A.
B.
C.
D.

Que: (12). What function is used to check if a value exists in an array in PHP?

A.
B.
C.
D.

Que: (13). What will be the output of the following PHP code snippet?

                            $array = [10, 20, 30, 40, 50];
echo array_sum($array);
                        
A.
B.
C.
D.

Que: (14). What function is used to merge the keys of two arrays in PHP?

A.
B.
C.
D.

Que: (15). What is the correct way to check if an array is empty in PHP?

A.
B.
C.
D.

Leave a comment