Examveda
Examveda

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

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

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

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

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

Answer: Option A

Solution(By Examveda Team)

The array_count_values() function counts all the values of an array and array_combine() combines arrays.

This Question Belongs to PHP >> Arrays

Join The Discussion

Comments ( 1 )

  1. CS VN
    CS VN :
    3 years ago

    bad webside;
    [A] => 2
    [Tiger] => 1

Related Questions on Arrays