I need to reverse the order of my feed so it displays as oldest item first.
I think i need to use the asort/usort function but I'm not sure where to start
I'm using the feed to populate the location drop down field in a form
<?php
header("Content-Type: text/html;charset=utf-8");
require("MagicParser.php");
function myRecordHandler($row)
{
echo "<option value=\"".$row['TITLE']."\">".$row['TITLE']."</option>\n ";
}
$url = "http://testflight.co.uk/feed?cat=9";
MagicParser_parse($url,"myRecordHandler","xml|RSS/CHANNEL/ITEM/");
?>
Hi Iain,
The trick is to load the rows into an array; reverse the array using PHP's array_revers() function, and then display as before using foreach() - have a go with something like this:
<?php
header("Content-Type: text/html;charset=utf-8");
require("MagicParser.php");
$rows = array();
function myRecordHandler($row)
{
global $rows;
$rows[] = $row;
}
$url = "http://testflight.co.uk/feed?cat=9";
MagicParser_parse($url,"myRecordHandler","xml|RSS/CHANNEL/ITEM/");
function myDisplayRecordHandler($row)
{
echo "<option value=\"".$row['TITLE']."\">".$row['TITLE']."</option>\n ";
}
$rows = array_reverse($rows);
foreach($rows as $row)
{
myDisplayRecordHandler($row);
}
?>
Hope this helps!
Cheers,
David
--
MagicParser.com