Which function returns an array consisting of associative key/value pairs?
Correct answer
C. array_count_values()
12 views
C. array_count_values()
12 views
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.
Not sure why the answer is C? Ask here and get an explanation.