PHP Array MCQs

This section focuses on "Array" in PHP. These Multiple Choice Questions (mcq) should be practiced to improve the PHP skills required for various interviews (campus interview, walk-in interview, company interview), placements, entrance exams and other competitive examinations.

1. How many types of array are available in php?

A. 1
B. 2
C. 3
D. 4

View Answer

2. By default, the index of array in php starts from ______?

A. 0
B. 1
C. -1
D. 2

View Answer

3. A ________ is an array with more than two dimensions.

A. single dimensional array
B. multi dimensional array
C. Both A and B
D. None of the above

View Answer

4. Which of the following are correct ways of creating an array?
i) arr[0] = "letsfindcourse";
ii) $arr[] = array("letsfindcourse");
iii) $arr[0] = "letsfindcourse";
iv) $arr = array("letsfindcourse");

A. ii), iii) and iv)
B. ii) and iii)
C. Only i)
D. iii) and iv)

View Answer

5. Which in-built function will add a value to the end of an array?

A. array_unshift()
B. into_array()
C. inend_array()
D. array_push()

View Answer

6. Which function returns an array consisting of associative key/value pairs?

A. count()
B. array_count()
C. array_count_values()
D. count_values()

View Answer

7. What will be the output of the following PHP code?

    $arr = array ("lets", "find", "course", ".Com");
    echo (array_search (".com", $arr) );

A. 0
B. Garbage value
C. 3
D. No Output

View Answer

8. As compared to associative arrays vector arrays are much

A. Faster
B. Slower
C. Stable
D. None of the above

View Answer

9. What is the output of the following php code?

 $alphabet = array ("A", "B", "C");
 echo (next($alphabet));

A. A
B. B
C. C
D. Error

View Answer

10. What is the output of the following php code?

 $alphabet  = array("A" => array
 ( "php" => "php 7.0", "date" => "3 December 2019"),
 "B" => array( "python" => "python 3.8.2",
 "date" => "24 December 2019") );
 echo $alphabet ["A"]["date"];

A. php 7.0
B. 3 December 2019
C. python 3.8.2
D. 24 December 2019

View Answer

Also check :


* You must be logged in to add comment.