1. Home
  2. Computer Science MCQs
  3. PHP
  4. Which function returns an array consisting of associative…

Added 19 Jan 2024

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

  1. count()
  2. array_count()
  3. array_count_values() Correct answer
  4. count_values()

Correct answer

C. array_count_values()

12 views

MCQSEXAM

Explanation

array_count_values() counts how many times each value occurs in an array and returns an associative array in which the keys are the original values and the values are their frequencies. For example, array_count_values(["a","b","a"]) gives ["a" => 2, "b" => 1].

count() only returns the total number of elements; the remaining options are not real functions.

Practise more Computer Science MCQs with answers and explanations on MCQsExam.com.

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More PHP MCQs

Practise all PHP MCQs

Similar MCQs