item_count

(ReachRSS >= 0.91)
item_count -- Returns the number of items contained in the specified channel

Description

int item_count ( channel_url )

This function returns the number of items currently cached for the specified channel. Note that depending on your max_items() and max_time() settings this number may not be equal to the total number of items in the raw XML feed, but instead contains the number of items that are currently cached.

If the channel does not exist in ReachRSS, item_count() will return false.

Example 1. item_count() example

$ReachRSS = new ReachRSS();
$ReachRSS->Startup();
$ReachRSS->add_channel("http://www.comicalert.com/public/popular24.xml");
$NbrItems = $ReachRSS->item_count("http://www.comicalert.com/public/popular24.xml");
print 'The Comic Alert! Popular channel contains '.$NbrItems.' cached items';

This example will subscribe ReachRSS to the "most popular comics" feed at Comic Alert! and then print the number of items to standard output.

Be careful not to confuse an item count of 0 with an error of FALSE. Here's how to tell the difference (notice the three equal signs (===) instead of usual two):

$NbrItems = $ReachRSS->item_count($ChannelURL);
if ($NbrItems===FALSE) {
  // the $ChannelURL we specified was invalid
  exit;
}
if ($NbrItems===0) {
  // the $ChannelURL was valid, but the channel contains 0 items
  exit;
}

See also item_property(), max_items(), max_time()

Back to Function List

 

Home | Features | Samples | Demo | Download | Register | Help / Support