note 54249 added to function.explode
| From: | janklopper dot at dot gmail dot dot dot com at osu1 dot php dot net | Date: | Tue, 28 Jun 2005 12:06:10 +0000 |
| Subject: | note 54249 added to function.explode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-91086@lists.php.net to get a copy of this message | ||
This is a better (altough untested) version of the lastword function, is searches from the end back
to the begin until it finds seperator, and thus only searches the smalest possible part of the
string. very helpfull for large strings.
function lastword($string,$seperator=" ") {//last word of a string
$count=strlen($string);
$count--;
for($i=$count;$i--;$i==0){
if($string[$i]==$seperator){
$location=$i-($i*2);
return substr($string,$location);
}
}
return;
}
----
Manual Page -- http://www.php.net/manual/en/function.explode.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54249
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54249&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54249&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54249&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54249&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54249&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54249&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54249&report=yes
Search -- http://master.php.net/manage/user-notes.php