...

View Full Version : use explode bu take last variable?



The_Walrus
03-10-2003, 01: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

field

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";
$a++;
}

firepages
03-10-2003, 02:54 AM
<?
echo $teamNAME[count($teamNAME)-1];
?>


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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum