"> What will be the output of the following PHP code?<?php$str

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

While sorting each character is compared with the others and sorted using ascii values therefore we the sorted array to be like option c.



Your comments will be displayed only after manual approval.