note 95171 deleted from function.strrpos by danbrown
| From: | danbrown@php.net | Date: | Wed, 16 Dec 2009 15:02:15 +0000 |
| Subject: | note 95171 deleted from function.strrpos by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-164048@lists.php.net to get a copy of this message | ||
Note Submitter: neobeetle
----
I couldn't find a function that would search a string for a min position of one of the chr of
an array. so this is my small function. If I'm wrong - please - correct me.
<?php
$array = array("!", "@", ":", ".", "/");
function strarr($string, $array, $offset)
{
$min=strlen($string);
foreach ($array as $v)
{
$pos = strpos($string, $v, $offset);
if($pos!="")
{
if($min>$pos)
{
$min=$pos;
}
}
}
return $min;
}
?>
If it didn't find any of the chr from the array, it will return the length of the whole string.
You are free to change it to false.