SimplePie 1.5 is now available!

SimplePie Documentation.  Learn how to use this thing.  It's way better than going to school.

You are here: Documentation » API Reference » SimplePie » get_item_quantity()



class SimplePie {
	get_item_quantity ( [int $max = 0] )

Returns the number of items in a feed. This is well-suited for for() loops.


  • Available since SimplePie 0.8.



The maximum number of items to return. If there are fewer items in the feed than what max is set to, SimplePie will return the lower number. Setting a value of 0 will return the number of items in the feed.


Loop through each item and do something with each

$feed = new SimplePie();
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="" xml:lang="en">
	<title>Sample SimplePie Page</title>
	<div class="header">
		<h1><a href="<?php echo $feed->get_permalink(); ?>"><?php echo $feed->get_title(); ?></a></h1>
		<p><?php echo $feed->get_description(); ?></p>
	$max = $feed->get_item_quantity(5);
	for ($x = 0; $x < $max; $x++):
		$item = $feed->get_item($x);
		<div class="item">
			<h2 class="title"><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h2>
			<?php echo $item->get_description(); ?>
			<p><small>Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></small></p>
	<?php endfor; ?>

See Also

reference/simplepie/get_item_quantity.txt · Last modified: 2011/03/06 03:56 (external edit)