0

Any chance the wonderful people here on daniweb could help me again with a loop? My apologies, loops are not my thing :| Basically what I'm trying to do is add a condition where on the last tweet (that is where the loop = $nooftweets), that tweet gets a different <span> class. Here's the function --

function get_tweets($twitter_id,
                    $nooftweets=3,
                    $dateFormat="m/d/y",
                    $includeReplies=false,
                    $dateTimeZone="America/New_York",
                    $beforeTweetsHtml="<ul>",
                    $tweetStartHtml="<li><p>",
                    $tweetMiddleHtml="&nbsp;&nbsp;<small>",
                    $tweetEndHtml="</small></p></li>",
                    $afterTweetsHtml="</ul>") {
 
    date_default_timezone_set($dateTimeZone);
    if ( $twitter_xml = twitter_status($twitter_id) ) {
        $result = $beforeTweetsHtml;
        foreach ($twitter_xml->status as $key => $status) {
            if ($includeReplies == true |
                    substr_count($status->text,"@") == 0 |
                    strpos($status->text,"@") != 0) {
                $message = processLinks($status->text);
                $result.=$tweetStartHtml.$message.$tweetMiddleHtml.
                            date($dateFormat,strtotime($status->created_at)).$tweetEndHtml;
                ++$i;
                if ($i == $nooftweets) break;
                }
            }
            $result.=$afterTweetsHtml;
    }
    else {
        $result.= $beforeTweetsHtml.
                    "<li id='tweet'>Twitter seems to be unavailable at the moment</li>".
                    $afterTweetsHtml;
    }
    echo $result;
}
1
Contributor
1
Reply
4
Views
6 Years
Discussion Span
Last Post by jrotunda85
0

Actually got it figured out, maybe I'm not as bad as loops as I thought... :scared:

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.