I'm currently designing a page, with 20 boxes, where each box represents an RSS feed, using simplepie as my parser.
Currently the script calls the first image from each feed, discards the rest and sets that image as the box's background-image.
With 20 feeds, I want to keep the code small and efficient as possible. Though I understand the separate setting of $feed01, $feed02 is a necessary messy evil, that's required for simplepie to work.
What I can't understand is why imageurl() returns a null value.
Can anyone educate me on why this could be?
Many Thanks
<?php
require_once('isnotabear/php/autoloader.php');
$feed01 = new SimplePie();
$feed01 -> set_feed_url ('http://link/to/rss01');
$success = $feed01 -> init();
$feed01 -> handle_content_type();
$max = $feed01 -> get_item_quantity(); // Where do we end?
$feed02 = new SimplePie();
$feed02 -> set_feed_url ('http://link/to/rss02');
$success = $feed02 -> init();
$feed02 -> handle_content_type();
$max = $feed02 -> get_item_quantity(); // Where do we end?
$start = (isset($_GET['start']) && !empty($_GET['start'])) ? $_GET['start'] : 0; // Where do we start?
$length = (isset($_GET['length']) && !empty($_GET['length'])) ? $_GET['length'] : 1; // How many per page?
function imageurl()
{
if ($success): foreach($feedin->get_items($start, $length) as $item): $feedin = $item-> get_feed();
{
$replace = preg_match( '@src="([^"]+)"@' , $item->get_content(), $match );
$match = preg_replace ('"src="', '', $match);
$match = str_replace('"', "'", $match);
echo $match[0];
}
endforeach;
endif;
};
?>
<!DOCTYPE HTML>
... YADA YADA YADA ...
<a href="#" style="background-image:url(<?php $feedin = $feed01; imageurl(); ?>)"><div> <span>FEED NAME</span></div></a>