Home » PHP » PHP Sorting Arrays » Question
  1. What will be the output of the following PHP code?
    <?php
    $First = array("Rahul","Ajit","Ats","Rahul","Ats","Sujit");
    $Second = array("Rahul","Rahul","Ajit","Rahul","Aju","Sujit");
    $Third = array_combine($First,$Second);
    print_r(array_count_values($Third));
    ?>
    1. Error
    2. Array
      (
      [Rahul]
      [Aju]
      [Sujit]
      )
    3. Array
      (
      [Rahul] => 2
      [Aju] => 1
      [Sujit] => 1
      )
    4. Nothing
    5. None of these
Correct Option: C

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



Your comments will be displayed only after manual approval.