"23", "Ats" => "21", "Aju" => "22");ksort($Str);foreach($Str as $s => $s_value){"> 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("Ajit" => "23", "Ats" => "21", "Aju" => "22");
    ksort($Str);
    foreach($Str as $s => $s_value)
    {
    echo "Key=" . $s . ", Value=" . $s_value;
    echo "\n";
    }
    ?>
    1. Error
    2. Nothing
    3. Key=Ajit, Value=23
      Key=Aju, Value=22
      Key=Ats, Value=21
    4. Key=Ajit, Value=23
      Key=Ats, Value=21
      Key=Aju, Value=22
    5. None of these
Correct Option: C

The ksort() function sorts an associative array in ascending order, according to the key.



Your comments will be displayed only after manual approval.