note 104615 added to function.substr
| From: | alex dot audu at garlandnetworx dot com | Date: | Sun, 26 Jun 2011 05:36:09 +0000 |
| Subject: | note 104615 added to function.substr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-180956@lists.php.net to get a copy of this message | ||
I used the following to return the first word in a string of words up to the first occurence of a
delimiter character.
$firstWord =
substr($wString, 0, -strrpos($wString, $delimiter));
For example: for
$wString = "This is great";
$delimiter = " ";
Then $firstWord = "This"
Cheers.
Alex.
----
Server IP: 69.147.83.197
Probable Submitter: 71.170.112.136
----
Manual Page -- http://www.php.net/manual/en/function.substr.php
Edit -- https://master.php.net/note/edit/104615
Del: integrated -- https://master.php.net/note/delete/104615/integrated
Del: useless -- https://master.php.net/note/delete/104615/useless
Del: bad code -- https://master.php.net/note/delete/104615/bad+code
Del: spam -- https://master.php.net/note/delete/104615/spam
Del: non-english -- https://master.php.net/note/delete/104615/non-english
Del: in docs -- https://master.php.net/note/delete/104615/in+docs
Del: other reasons-- https://master.php.net/note/delete/104615
Reject -- https://master.php.net/note/reject/104615
Search -- https://master.php.net/manage/user-notes.php