I'm using this code for my PHP XML pagination.
<?php
$xml = simplexml_load_file('yourxml.xml');
$limit = 5;
$page = $_GET['page'];
foreach ( $xml->item as $item ) {
if ( empty($page) ) {
if ( $item->attributes()->page > 0 && $item->attributes()->page <= $page+$limit )
echo $item->attributes()->title,'<br/>';
} else {
if ( $item->attributes()->page > ($page-1)*$limit && $item->attributes()->page <= (($page- 1)*$limit)+$limit )
echo $item->attributes()->title,'<br/>';
}
}
?>
The problem is that it uses foreach loop to read the elements of the XML file. Making the page 1 attribute the first to show up instead of the last page number. I need to show the XML file from last page to the page 1, instead of page 1 to the last page. How could I achieve this? This is to show the most recent entry entered from the XML.