Sunday, 27 March 2011

Small Changes

Just wanted to change the 'ches_cat' (the name of my twitter account) to 'me' in each of the twitter items. To do this I used the string replace, which searches each string and replaces a particular word or pattern:


//changing ches_cat in the feed to me, for all the first 20 feeds. 
  for ($i = 0; $i < 20; $i++) {
    $twitterxml->channel->item[$i]->title = str_replace('ches_cat',
        'me', $twitterxml->channel->item[$i]->title);
}


Now all matches found with 'ches_cat' are replaced with 'me', for the first 20 items. (this is how many the feed is taking)

No comments:

Post a Comment