Web Designing MCQs

20 Objective Questions on Arrays in PHP

Google+ Pinterest LinkedIn Tumblr
Here are the collections of the top 20 objective questions on arrays in PHP includes multiple-choice questions on the different types of functions used on the array manipulation task in PHP. It includes objective questions on different tasks such as combining, merging, slicing, splicing, and dissecting arrays along with the functions for returning a random set of keys, adding and subdividing an array in PHP.

Read Also: Top 20 MCQ Questions on Arrays in PHP

1. The … function will pass each element of an array to the user-defined function.
A) array_walk()
B) walk()
C) array_walk_recursive()
D) array_work()

2. … function is useful when you need to perform a particular action based on each array element.
A) array_walk()
B) walk()
C) array_walk_recursive()
D) array_work()

3. … function is capable to recursively apply a user-defined function to every element in an array.
A) array_walk()
B) walk()
C) array_walk_recursive()
D) array_work()

4. … function works functionally the same as count().
A) size()
B) sizeof()
C) countof()
D) countall()

5. The … function returns an array consisting of associative key/value pairs.
A) array_count()
B) array_count_keys()
C) count()
D) array_count_values()

6. The … function removes all duplicate values found in an array, returning an array consisting of solely unique values.
A) array_duplicate()
B) array_unique()
C) array_remove_duplicate()
D) array_unique_values()

7. The … function reverses the roles of the keys and their corresponding values in an array.
A) array_reverse()
B) array_flip()
C) array_flip_roles()
D) array_reverse_roles()

8. The … function returns a section of an array based on a starting and ending offset value.
A) array_slice()
B) array_flip()
C) array_splice()
D) array_reverse()

9. The … function produces a new array consisting of a submitted set of keys and corresponding values.
A) array_merge()
B) array_combine()
C) array_merge_recursive()
D) array_merge_all()

10. … will simply overwrite the preexisting key/value pair, replacing it with the one found in the current input array.
A) array_merge()
B) array_combine()
C) array_merge_recursive()
D) array_merge_all()

11. … will merge the values together, forming a new array with the preexisting key as its name.
A) array_merge()
B) array_combine()
C) array_merge_recursive()
D) array_merge_all()

12. The … function removes all elements of an array found within a specified range, returning those removed elements in the form of an array.
A) array_slice()
B) array_remove()
C) array_remove_all()
D) array_splice()

13. The … function returns a key-preserved array consisting only of those values present in the first array that are also present in each of the other input arrays.
A) array_common()
B) array_intersect()
C) array_intersect_key()
D) array_intersect_ukey()

14. The … function will return keys located in an array that is located in any of the other provided arrays.
A) array_common()
B) array_intersect()
C) array_intersect_key()
D) array_intersect_ukey()

15. The … function allows you to compare the keys of multiple arrays with the comparison algorithm determined by a user-defined function.
A) array_common()
B) array_intersect()
C) array_intersect_key()
D) array_intersect_ukey()

16. The function … returns those values located in the first array that are not located in any of the subsequent arrays.
A) diff()
B) array_diff()
C) array_diff_key()
D) array_diff_ukey()

17. The function … allows you to compare the keys of multiple arrays with the comparison algorithm determined by a user-defined function.
A) diff()
B) array_diff()
C) array_diff_key()
D) array_diff_ukey()

18. The function … will return a random number of keys found in an array.
A) rand()
B) array_random()
C) array_rand()
D) array_rand_key()

19. The … function adds all the values of input_array together, returning the final sum.
A) array_sum()
B) array_final_sum()
C) array_add()
D) array_sum_values()

20. The … function breaks the input array into a multidimensional array that includes several smaller arrays consisting of size elements.
A) array_size()
B) array_fragments()
C) array_chunk()
D) chunk()

Answers

  1. A) array_walk()
  2. A) array_walk()
  3. C) array_walk_recursive()
  4. B) sizeof()
  5. D) array_count_values()
  6. B) array_unique()
  7. B) array_flip()
  8. A) array_slice()
  9. B) array_combine()
  10. A) array_merge()
  11. C) array_merge_recursive()
  12. D) array_splice()
  13. B) array_intersect()
  14. C) array_intersect_key()
  15. D) array_intersect_ukey()
  16. B) array_diff()
  17. D) array_diff_ukey()
  18. C) array_rand()
  19. A) array_sum()
  20. C) array_chunk()

Shuseel Baral is a web programmer and the founder of InfoTechSite has over 8 years of experience in software development, internet, SEO, blogging and marketing digital products and services is passionate about exceeding your expectations.

Write A Comment