Home » PHP » PHP Sorting Arrays » Question
  1. What will be the output of the following PHP code ?
    <?php
    $Color = array("R" => "Red", "G" => "Green", "B" => "Blue", "Y" => "Yellow");
    $Result = array_flip($Color);
    print_r($Result);
    ?>
    1. Array
      (
      [Red] => R
      [Green] => G
      [Blue] => B
      [Yellow] => Y
      )
    2. Error
    3. Array
      (
      [Red] => R
      [Green] => G
      )
    4. Nothing
    5. None of these
Correct Option: A

The array_flip() function flips/exchanges all keys with their associated values in an array.



Your comments will be displayed only after manual approval.