note 13906 added to function.array-intersect.php
| From: | jhilgeman at ecx dot com | Date: | Mon, 09 Jul 2001 20:52:12 +0000 |
| Subject: | note 13906 added to function.array-intersect.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-15132@lists.php.net to get a copy of this message | ||
If you are intersecting a "normal index" array with an array that has an associative index
and you want to keep the associative index, put the associative array as the second argument:
$AssociativeArray["cat"] = "Fluffy";
$AssociativeArray["dog"] = "Wetspot";
$WhichToAdoptArray[] = "Fluffy";
$Intersected_One = array_intersect ($AssociativeArray,$WhichToAdoptArray);
$Intersected_Two = array_intersect ($WhichToAdoptArray,$AssociativeArray);
$Intersected_One will be look like:
$Intersected_One[0] == "Fluffy";
but $Intersected_Two will be:
$Intersected_Two["cat"] == "Fluffy";
http://www.php.net/manual/en/function.array-intersect.php