note 53618 added to function.strpos
| From: | nicolasATsmileandsoftDOTcomDOTar at osu1 dot php dot net | Date: | Tue, 07 Jun 2005 13:45:33 +0000 |
| Subject: | note 53618 added to function.strpos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-90061@lists.php.net to get a copy of this message | ||
Last position of needle in haystack:
<?
function istrpos($needle, $haystack, $offset=0)
{
return (int) strlen( $haystack ) - strpos ( strrev ( $haystack ) , $needle ) + $offset;
}
$phrase = "jose//pepe/micasa/pepepe";
echo istrpos( "/" , $phrase ); //returns last position of "/" in $phrase
result:18
echo istrpos( "/" , $phrase , -1 ); //returns last position of "/" in $phrase
MINUS 1 result:17
echo substr( $phrase, istrpos( "/" , $phrase ) ); //returns "pepepe"
echo substr( $phrase, istrpos( "/" , $phrase , -1 ) ); //returns "/pepepe"
?>
----
Manual Page -- http://www.php.net/manual/en/function.strpos.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+53618
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53618&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53618&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53618&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53618&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53618&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+53618&report=yes
Search -- http://master.php.net/manage/user-notes.php