Call us Toll-Free:
1-800-218-1525
Live ChatEmail us

 Sponsors

Demonstrating array intersect

Code Wizard, 12-30-2006

array_intersect() returns an array containing all the values of array1 that are present in all the arguments. Note that keys are preserved.

<?php
$array1 = array("OH","CA","NY","HI","CT");
$array2 = array("OH","CA","HI","NY","IA");
$array3 = array("TX","MD","NE","OH","HI");
$intersection = array_intersect($array1, $array2, $array3);
print_r($intersection);

// from "Beginning PHP 5 and MySQL: From Novice to Professional", courtesty apress.com
?>
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions