houghi wrote:
Quote:
I have a parameter $name that contavins e.g. "Turn left at Blooming
Grove Turnpike/Quassaic Turnpike/RT-94 Continue to follow RT-94".
I just want to have the last word. The number of words will be different
each time.
>
I looked at http://be.php.net/manual/en/book.strings.php but I either
did not see it or I am looking at the wrong place (or both)
>
houghi
|
Well, you could use something like:
$name = trim($name); // Strip leading/trailing white space
$pos = strrpos($name, ' '); Find the last space
if ($pos === false) // If there is none
$word = $name; // Then only one word
else
$word = substr($name, $pos+1); // Get everything following the space
echo $word;
Assuming, of course, you always have a space as a word separator.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================