Help with simplepie and twitter feed

Discussion in 'PHP' started by crazyfish, Apr 17, 2009.

  1. #1
    I'm trying to add a retweet button to a small page I am creating using simplepie to parse a twitter feed, anyways I ran into a small problem. Currently I am using this to should the authors name:

    <?php $author = $item->get_author(); echo $author->get_name(); ?>
    Code (markup):
    But it displays myusername (Bob Smith) so the retweet ends up being "RT @myusername (Bob Smith) then the tweet"

    Anyone know how I can strip out the (Bob Smith) part and just leave myusername?

    Thanks in advance!
     
    crazyfish, Apr 17, 2009 IP
  2. emed

    emed Peon

    Messages:
    70
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you can use explode:
    <?php
    $author = $item->get_author();
    $author = explode(' ',$author->get_name());
    $author = $author[0];
    echo $author;
    ?>
    PHP:
     
    emed, Apr 17, 2009 IP
  3. crazyfish

    crazyfish Active Member

    Messages:
    1,110
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    80
    #3
    Hey that worked. What does explode do?
     
    crazyfish, Apr 19, 2009 IP
  4. emed

    emed Peon

    Messages:
    70
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #4
    explode split a string into array

    example:
    <?php
    $string = "one#two#three";
    $array = explode("#", $string);
    
    echo $array[0]; //Output: one
    
    echo $array[1]; //Output: two
    
    echo $array[2]; //Output: three
    
    PHP:
    http://www.php.net/explode
     
    emed, Apr 19, 2009 IP
  5. crazyfish

    crazyfish Active Member

    Messages:
    1,110
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    80
    #5
    Ahhh ok, thanks for the explaination.
     
    crazyfish, Apr 20, 2009 IP