array_intersect()
| From: | Chris Lee | Date: | Fri, 19 Jan 2001 21:39:20 +0000 |
| Subject: | array_intersect() | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-35732@lists.php.net to get a copy of this message | ||
Ok I thought array_intersect() was the function I was looking for, I might
have to write my own.
I want an array with ONLY the keys/values that are present in all the
variables; ie.
<?
$test_a[] = '974806802083190501';
$test_a[] = '974806802083190503';
$test_a[] = '974806802083190504';
$test_b[] = '974806802083190501';
$new_array = array_intersect($test_a, $test_b);
print_r($new_array);
?>
Array
(
[0] => 974806802083190501
[1] => 974806802083190503
[2] => 974806802083190504
)
<?
$test_a[] = '501';
$test_a[] = '503';
$test_a[] = '504';
$test_b[] = '501';
$new_array = array_intersect($test_a, $test_b);
print_r($new_array);
?>
Array
(
[0] => 501
)
array_insersect() only seems to work with small numbers... or small text.
Chris Lee
Mediawaveonline.com