note 56348 added to function.strpos
| From: | talthen at wp dot pl | Date: | Wed, 31 Aug 2005 10:48:41 +0000 |
| Subject: | note 56348 added to function.strpos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-94517@lists.php.net to get a copy of this message | ||
Because I like the way pascal functions work, so I created this little function:
function paspos($base,$findme)
{
$result=strpos($base,$findme);
if ($result===false) $result=-1;
return $result;
}
It returns -1 if the $findme may not be found in $base, or position where $findme was found in
$base.
Now when you want to check if $base starts from $findme you can just type:
if (paspos($string,$searchfor)==0)) ....
Hope you'll like it :)
----
Manual Page -- http://www.php.net/manual/en/function.strpos.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56348
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56348&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56348&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56348&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56348&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56348&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56348&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56348&report=yes
Search -- http://master.php.net/manage/user-notes.php