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!
you can use explode: <?php $author = $item->get_author(); $author = explode(' ',$author->get_name()); $author = $author[0]; echo $author; ?> PHP:
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