Trim the first 2 words of an echo

Discussion in 'PHP' started by Al Capone, May 29, 2008.

  1. #1
    I want to display

    $names

    but all the names are "User Name Jack", "User Name Joe"

    when I...
    echo $names;

    I want to just show "Jack" and "Joe"


    how do i trim the "User Name " using php (not changing the database)?

    Thanks!
     
    Al Capone, May 29, 2008 IP
  2. coffeesonnow

    coffeesonnow Peon

    Messages:
    34
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <?php

    $names1 = str_replace("User Name ","" , $names);
    echo $names1;

    ?>

    should work.
     
    coffeesonnow, May 29, 2008 IP
    Al Capone likes this.
  3. Al Capone

    Al Capone Well-Known Member

    Messages:
    784
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    140
    #3
    Worked like a charm, rep given :)
     
    Al Capone, May 29, 2008 IP