Toggle navigation
Home
Latest pastes
FAQ
Random
Register
Login
Compare the keys and values of three arrays (use a user-defined function to compare the keys), and return the matches:
SUBMITTED BY:
henry1874w
DATE:
June 23, 2017, 9:35 p.m.
FORMAT:
Text only
SIZE:
334 Bytes
Raw
Download
Tweet
HITS:
236
Go to comments
Report
<?php
function myfunction($a,$b)
{
if ($a===$b)
{
return 0;
}
return ($a>$b)?1:-1;
}
$a1=array("a"=>"red","b"=>"green","c"=>"blue");
$a2=array("a"=>"red","b"=>"green","d"=>"blue");
$a3=array("e"=>"yellow","a"=>"red","d"=>"blue");
$result=array_intersect_uassoc($a1,$a2,$a3,"myfunction");
print_r($result);
?>
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus