"Ajit", "002" => "Rahul", "003" => "Ats", "004" => "Aju");$Second = array("005""> What will be the output of the following PHP code?<?php$First

Home » PHP » PHP Sorting Arrays » Question
  1. What will be the output of the following PHP code?
    <?php
    $First = array("001" => "Ajit", "002" => "Rahul", "003" => "Ats", "004" => "Aju");
    $Second = array("005" => "Ajit", "006" => "Rahul", "007" => "Ats", "008" => "Sujit");
    $Third = array("009" => "Sujit");
    $Forth = array_merge($Second, $Third);
    $Result = array_diff($First, $Forth);
    print_r($Result);
    ?>
    1. Error
    2. Array
      (
      [004] => Aju
      )
    3. Nothing
    4. Array
      (
      [001] => Aju
      )
    5. None of these
Correct Option: B

The array_diff() function compares the values of two (or more) arrays, and returns the differences. This function compares the values of two (or more) arrays, and return an array that contains the entries from array1 that are not present in other arrays (array2, array3, etc).



Your comments will be displayed only after manual approval.