Voting

: max(nine, eight)?
(Example: nine)

The Note You're Voting On

Malte
17 years ago
Extending the posting by Terry from 07-Feb-2006 04:42:

If you want to use this function with arrays which have sometimes the same value several times, it won't be checked if they're existing in the second array as much as in the first.
So I delete the value in the second array, if it's found there:

<?php
$firstarray
= array(1, 1, 2, 3, 4, 1);
$secondarray = array(4, 1, 6, 5, 4, 1);

//array_intersect($firstarray, $secondarray): 1, 1, 1, 4

foreach ($firstarray as $key=>$value){
if (!
in_array($value,$secondarray)){
unset(
$firstarray[$key]);
}else{
unset(
$secondarray[array_search($value,$secondarray)]);
}
}

//$firstarray: 1, 1, 4

?>

<< Back to user notes page

To Top