Php programming language MCQ : Arrays - Link1

Php programming language MCQ : Arrays: Link1

Arrays MCQ

       Are you worried about the answers to PHP programming-Arrays-Indexed Vs Associative arrays questions? We have arranged the Show Answer button under the each question. Candidates can click on it to know the right option among the given alternatives. Furthermore, the applicants can check our web portal @ www.totalmcq.com to take part in more MCQ on various subject. Wish, the given information about the Arrays MCQ will helpful to the advance and can learn the various types of questions and answers.


Q.1. Array values are keyed by ------ values (called indexed arrays) or using ------ values (called associative arrays).

A. Positive number, negative number                                                              B. Even number, string
C. String, Boolean                                                       D. Integer, string

Q.2. What will the following script output?

 <?php \\
     \$array = array(1,3,5,7,11,13,15); \\
     \$sum = 0; \\
         for(\$i=0;\:\$i<5\:;\$i++) \\
                 \{ \\
             \$sum+= \$array[\$array[\$i]];   \\
 \} \\
                 echo\:\: \$sum;\\ 
?>

A. 32                                                              B. 18
C. Null                                                       D. 0

Q.3. There are three different kind of arrays---------.

A. A) Numeric array, String array, Multidimensional array
B. Numeric array, Associative array, Dimensional array
C. Numeric array, Associative array, Multidimensional array
D. Const array, Associative array, Multidimensional array

Q.4. By default, the index of array in php starts from -----.

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

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

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

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

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

Q.7. Which function can be used to move the pointer to the previous array position?

A. last()
B. before()
C. previous()
D. prev()

Q.8. 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()

Q.9. Which of the following PHP function will return true if a variable is an array or false if it is not an array?

A. this_array()
B. is_array()
C. do_array()
D. in_array()

Q.10. What will be the output of the following PHP code?

 <?php \\
     \$fruits = array("apple", "orange", array ("pear", "mango"),
    "banana"); \\
    echo (count(\$fruits, 1));\\ 
?>

A. 6                                                                                B. 5
C. 3                                                                             D. 4