|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-01-12 15:27 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 15:00:01 2025 UTC |
Description: ------------ This is the existing code i Found in php.net manual, It has 3 parameters, what is the purpose of 3rd parameter. If it is going to check from 3rd array also any intersecting elements. I tried code below with 3 arrays but it displayed me empty array. Working Code from PHP manual: ******************************************************************* array array_diff ( array array1, array array2 [, array ...] ) array_diff() returns an array containing all the values of array1 that are not present in any of the other arguments. Note that keys are preserved. Example 1. array_diff() example <?php $array1 = array("a" => "green", "red", "blue", "red"); $array2 = array("b" => "green", "yellow", "red"); $result = array_diff($array1, $array2); print_r($result); ?> Multiple occurrences in $array1 are all treated the same way. This will output : Array ( [1] => blue ) ********************************************************************** ********************************************************************** Reproduce code: --------------- Code i Tried: ********************************************************************** <?php $array1 = array("a" => "green", "red", "blue","white"); $array2 = array("b" => "green", "yellow", "red"); //$array3 = array("white"); $array3 = array(); $result = array_intersect($array1, $array2,$array3); print_r($result); ?> // Output Array ( ) an empty Array ********************************************************************** Expected result: ---------------- it should check in the 3rd array also for any intersecting elements and then it should display the elements from array1 which are intersecting with either 2nd or 3rd array. Actual result: -------------- An empty Array