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...


>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 docs but im not sure...
>PHP General Mailing List (
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]

Jim Musil
Multimedia Programmer

PHP General Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to