We have 19 guests online
PHP Scripts arrow Free PHP Tutorials arrow Free PHP Tutorials arrow PHP Tutorials and Examples arrow PHP 
Free PHP Tutorials arrow PHP Tutorials and Examples arrow PHP

Demonstrating array_intersect() - finding common values across many arrays
User Rating: / 2
PoorBest 
array_intersect() takes two or more arrays as arguments. The  function returns an array of "intersections", or identical values that are present in each of the other arrays. Note that keys are preserved.

 

  1. <?php
  2.    $array1 = array("OH","CA","NY","HI","CT");
  3.    $array2 = array("OH","CA","HI","NY","IA");
  4.    $array3 = array("TX","MD","NE","OH","HI");
  5.    $intersection = array_intersect($array1, $array2, $array3);
  6.    print_r($intersection);
  7.    
  8.    // from "Beginning PHP 5 and MySQL: From Novice to Professional", courtesty apress.com
  9. ?>

 

 

Directory Stats

There are 1036 listing and 46 categories in our website

Change Language