note 56348 deleted from function.strpos by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 16:39:04 +0000 |
| Subject: | note 56348 deleted from function.strpos by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154872@lists.php.net to get a copy of this message | ||
Note Submitter: talthen at wp dot pl
----
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 :)