Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2003
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    use explode bu take last variable?

    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?

    PHP Code:
     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++;
        } 

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,073
    Thanks
    11
    Thanked 98 Times in 96 Posts
    PHP Code:
    <?
    echo $teamNAME[count($teamNAME)-1]; 
    ?>
    if $teamNAME was numeric (which I guess it aint ) you could probably just echo max($teamNAME);
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    New Coder
    Join Date
    Jan 2003
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation YES!!!!

    thank you so very much that worked beautifully and much easier than I expected!!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •