"Red", "B" => "Green", "C" => "Blue", "D" => "Yellow");$Color2 = array("E""> What will be the output of the following PHP code ?<?php$Color1

Home » PHP » PHP Arrays » Question
  1. What will be the output of the following PHP code ?
    <?php
    $Color1 = array("A" => "Red", "B" => "Green", "C" => "Blue", "D" => "Yellow");
    $Color2 = array("E" => "Red","F" => "Green", "H" => "Blue");
    $Result = array_intersect($Color1, $Color2);
    print_r($Result);
    ?>
    1. Nothing
    2. Array
      (
      [A] => Red
      [B] => Green
      [C] => Blue
      )
    3. Array
      (
      [A] => Red
      )
    4. Error
    5. None of these
Correct Option: B

The array_intersect() function compares the values of two (or more) arrays, and returns the matches.



Your comments will be displayed only after manual approval.