PHP Array MCQs

11. Keys in array can be non-sequential.

A. True
B. False
C. Depend on program
D. Keys does not exist in array

View Answer


12. Key/value pair can be initialized using = operator?

A. True
B. False
C. Depend on program
D. Keys does not exist in array

View Answer


13. What is the use of is_array() function?

A. Function is used to print the array in readable format.
B. Adds elements to the beginning of the array and returns the size of array.
C. Function can be used to verify if a variable is an array. Returns TRUE or FALSE
D. Adds elements to the end of the array and returns the size of array.

View Answer


14. What is the use of array_unshift() function?

A. Function is used to print the array in readable format.
B. Adds elements to the beginning of the array and returns the size of array.
C. Function can be used to verify if a variable is an array. Returns TRUE or FALSE
D. Adds elements to the end of the array and returns the size of array.

View Answer


15. What is the use of array_flip() function?

A. Rearranges the array elements in the reverse order
B. Is used to convert the keys to values and values to keys.
C. Can be used to fetch the keys present in the array
D. Returns number of elements in the array

View Answer


16. What is the use of array_values() function?

A. Returns all the values of the respective keys present in the passed array
B. Returns number of elements in the array
C. Can be used to fetch the keys present in the array
D. Returns the values and the frequency of each value in form of an array.

View Answer


17. Predict the output of the following code.

<?php

$a=array(1,2,3,5,6);
next($a);
next($a);
next($a);
echo current($a);

?>

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

View Answer


18. Predict the output of the following PHP code.

<?php

$fruits = array ("apple", "orange", "banana", "guava", "pine-apple", "papaya", "melon");
next($fruits);
next($fruits);
prev($fruits);

?>

A. guava
B. banana
C. orange
D. pine-apple

View Answer


19. Which of the following function is used to get the value of the previous element in an array?

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

View Answer


20. Which of the following function is Used to set the array pointer to the value of last key?

A. last()
B. end()
C. next()
D. final()

View Answer





Discussion


* You must be logged in to add comment.