note 47261 added to function.in-array
| From: | darkspectrum at gmail dot com | Date: | Tue, 09 Nov 2004 00:01:54 +0000 |
| Subject: | note 47261 added to function.in-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-80304@lists.php.net to get a copy of this message | ||
I couldn't seem to find any function that would only return true if every value in the needle
array was found in the haystack. So here is what I came up with...
<?
function ArrayIsInArray($needle, $haystack)
{
foreach ($needle as $nee)
{
if (in_array($nee,$haystack))
$inarray[] = true;
}
if (sizeof($inarray) == sizeof($needle)) return true;
else return false;
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.in-array.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+47261
Delete -- http://master.php.net/manage/user-notes.php?action=delete+47261&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47261&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47261&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47261&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47261&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47261&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+47261&report=yes
Search -- http://master.php.net/manage/user-notes.php