note 28020 added to function.strpos
| From: | netmail at brownfloyd dot com | Date: | Mon, 30 Dec 2002 04:31:19 +0000 |
| Subject: | note 28020 added to function.strpos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-41450@lists.php.net to get a copy of this message | ||
Description:
array straipos ( string haystack, array needle [, int offset])
Returns an indexed array of the item from the array 'needle' that occurs first in the
haystack, with item 0 being its position in the 'haystack', and item 1 being the item
number of the item found.
If none of the items are found, it returns false.
function straipos($haystack,$array,$offset=0)
{
$occ = Array();
for ($i = 0;$i<sizeof($array);$i++)
{
$pos = strpos($haystack,$array[$i],$offset);
if (is_bool($pos)) continue;
$occ[$pos] = $i;
}
if (sizeof($occ)<1) return false;
ksort($occ);
reset($occ);
list($key,$value) = each($occ);
return Array($key,$value);
}
--
http://www.php.net/manual/en/function.strpos.php
http://master.php.net/manage/user-notes.php?action=edit+28020
http://master.php.net/manage/user-notes.php?action=delete+28020
http://master.php.net/manage/user-notes.php?action=reject+28020