Forum Moderators: coopster

Message Too Old, No Replies

Reducing number of characters

         

Jim123

11:45 pm on Feb 2, 2011 (gmt 0)

10+ Year Member



I'm using this code for getting a tweet on my website and it works great.

function wp_echoTwitter($username){
include_once(ABSPATH.WPINC.'/rss.php');
$tweet = fetch_rss("http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1"); ?>
<a href="http://www.twitter.com/sonyonline" target="_blank"><?php echo $tweet->items[0]['atom_content']; ?></a>
<?php }


To call it I use this

<?php wp_echoTwitter('webmasterworld'); ?>


The tweet is sometimes to big and I want to reduce the number of characters of the tweet followed by ... at the end (so reduced tweet + ...), but I don't have a clue how to do this.

Can anyone help me with this?

Appreciated!
Thanks
Jim

omoutop

2:15 pm on Feb 3, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The substr() [php.net] will do the trick

Jim123

11:27 pm on Feb 3, 2011 (gmt 0)

10+ Year Member



Thanks omoutop, I managed.

<?php echo substr($tweet->items[0]['atom_content'], 0, 75).'...'; ?>