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_items()



class SimplePie {
	get_items ( [int $start = 0 [, int $length = 0] ] )

Returns an array of SimplePie_Item references for each item in the feed, which can be looped through.

This is better suited for foreach() loops, whereas get_item() is better suited for for() loops.


  • Available since SimplePie Beta 2.



The number of the item you want to start at. Remember that arrays begin with 0, not 1.


The number of items to return. 0 will return all. The start parameter is required if this is used.


Loop through the first 5 itemss 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>
	<?php foreach ($feed->get_items(0, 5) as $item): ?>
		<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 endforeach; ?>

See Also

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