Re: substr trim functions..
| From: | jimtronic | Date: | Fri, 14 Dec 2001 17:15:17 +0000 |
| Subject: | Re: substr trim functions.. | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-77764@lists.php.net to get a copy of this message | ||
There are no shortage of ways to do this.
// Using explode() ...
echo array_pop(explode(" ",$full_name));
// Using split() ...
echo array_pop(split(" ",$full_name));
// Using stristr() ....
while($haystack = stristr($haystack," ")) {
$haystack = substr($haystack,1);
$last_word = $haystack;
}
echo "$last_word";
Plus all the preg_match and regular expression functions...
http://php.net/explode
http://php.net/split
http://php.net/stristr
jim
I trying to convert some full names to last names only like: -get the subtext from the end until the space "joe blue" -> "blue" "bill western" - "western" Looked around at php.net docs but im not sure... Thanks Andras -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net-- Jim Musil --------- Multimedia Programmer Nettmedia ------------- 212-629-0004 jim@nettmedia.com