note 8918 added to strrev
| From: | uioreanu at hotmail dot com | Date: | Fri, 06 Oct 2000 01:45:31 +0000 |
| Subject: | note 8918 added to strrev | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-6133@lists.php.net to get a copy of this message | ||
Hi,
I'm Calin Uioreanu from Romania.
For finding the last word of a phrase, i think a nice way would be:
<?
$str="1adas 2asd 3asdas 4asdasd";
$LastSpacePos = strlen ($str) - strpos(strrev($str), " ");
$LastWord = substr ($str, $LastSpacePos, strlen($str));
echo "<br>LastSpacePos=$LastSpacePos";
echo "<br>LastWord=$LastWord";
?>
http://www.php.net/manual/function.strrev.php