Home » PHP » PHP Arrays » Question
  1. What will be the output of the following PHP code?
    <?php
    $Color = array("Green", "White", "Green", "Red", "Yellow", "White");
    print_r(array_count_values($Color));
    ?>
    1. Array
      (
      [Green] => 2
      [White] => 2
      [Red] => 1
      [Yellow] => 1
      )
    2. Array
      (
      [Green] => 2
      [Yellow] => 1
      )
    3. Array
      (
      [Red] => 1
      [Yellow] => 1
      )
    4. Array
      (
      [Green] => 2
      [White] => 2
      )
    5. None of these
Correct Option: A

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



Your comments will be displayed only after manual approval.