Examveda
Examveda

What will be the output of the following PHP code?
<?php
$a = array("A", "Cat", "Dog", "A", "Dog");
print_r(array_count_values($a));
?>

A. Array ( [A] => 2 [Cat] => 1 [Dog] => 2 )

B. Array ( [A] => 2 [Cat] => 2 [Dog] => 1 )

C. Array ( [A] => 1 [Cat] => 1 [Dog] => 2 )

D. Array ( [A] => 2 [Cat] => 1 [Dog] => 1)

Answer: Option A

Solution(By Examveda Team)

The array_count_values() function counts all the values of an array.

This Question Belongs to PHP >> Arrays

Join The Discussion

Related Questions on Arrays