note 95171 added to function.strrpos
| From: | neobeetle at osu1 dot php dot net | Date: | Wed, 16 Dec 2009 14:47:46 +0000 |
| Subject: | note 95171 added to function.strrpos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-164046@lists.php.net to get a copy of this message | ||
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.
$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.
----
Server IP: 69.147.83.197
Probable Submitter: 92.112.2.118
----
Manual Page -- http://www.php.net/manual/en/function.strrpos.php
Edit -- https://master.php.net/note/edit/95171
Del: integrated -- https://master.php.net/note/delete/95171/integrated
Del: useless -- https://master.php.net/note/delete/95171/useless
Del: bad code -- https://master.php.net/note/delete/95171/bad+code
Del: spam -- https://master.php.net/note/delete/95171/spam
Del: non-english -- https://master.php.net/note/delete/95171/non-english
Del: in docs -- https://master.php.net/note/delete/95171/in+docs
Del: other reasons-- https://master.php.net/note/delete/95171
Reject -- https://master.php.net/note/reject/95171
Search -- https://master.php.net/manage/user-notes.php