Home » PHP » PHP Arrays » Question
  1. What will be the output of the following PHP code?
    <?php
    $City = array("A"=>"Chennai", "B"=>"Noida", "C"=>"Delhi");
    echo array_shift($City);
    print_r ($City);
    ?>
    1. ChennaiArray
      (
      [C] => Delhi
      )
    2. ChennaiArray
      (
      [B] => Noida
      [C] => Delhi
      )
    3. Array
      (
      [B] => Noida
      [C] => Delhi
      )
    4. ChennaiArray
      (
      Noida
      Delhi
      )
    5. None of these
Correct Option: B

The array_shift() function removes the first element from an array, and returns the value of the removed element.



Your comments will be displayed only after manual approval.