note 28020 deleted from function.strpos by tularis
| From: | tularis@php.net | Date: | Wed, 22 Aug 2007 13:26:25 +0000 |
| Subject: | note 28020 deleted from function.strpos by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-129700@lists.php.net to get a copy of this message | ||
Note Submitter: netmail at brownfloyd dot com
----
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.
<?php
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);
}
?>