View Full Version : use explode bu take last variable?

03-10-2003, 02:59 AM
I have a field that some times has 3 words seperated by " " and sometimes 2. I want only to get the last word....i.e


goofey dog
mickey whatever mouse
donald the duck
minnie mouse

currently my explode would pull dog, whatever, the, mouse

I want to get dog, mouse, duck, mouse. Any ideas?

while ($teamROW = mysql_fetch_array($teamRSLT))
$nameTEAM[$a] = $teamROW[1];
$teamNAME = explode(" ", $teamROW[1]);
$teamLIST[$a] = $teamNAME[1];
echo "<tr class=".$teamLIST[$a]."><td>".$teamROW[1]."</td></tr>\n";

03-10-2003, 03:54 AM
echo $teamNAME[count($teamNAME)-1];

if $teamNAME was numeric (which I guess it aint :) ) you could probably just echo max($teamNAME);

03-10-2003, 01:45 PM
thank you so very much that worked beautifully and much easier than I expected!!!