note 45694 deleted from function.in-array by tomsommer
| From: | tomsommer@php.net | Date: | Wed, 15 Sep 2004 15:46:01 +0000 |
| Subject: | note 45694 deleted from function.in-array by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-76741@lists.php.net to get a copy of this message | ||
Note Submitter: dale dot liszka at gmail dot com
----
A faster approach than mina86's function for very large arrays
Instead of searching the entire array for a value, just use an associative array and use isset().
This way the lookup is in one pass intead of iterating the whole array.
//Create associative lookup array
while($data){
$lookup_arr[array_pop($data)]++;
}
//now the quicker search
foreach($find_us as $find_me){
if(isset($lookup_arr[$find_me])){
echo "Found $find_me!\n";
}
}