Invert display of Xml in PHP

1

How do I reverse the display of an xml in PHP? Code:

$xml = simplexml_load_file('link.xml');
foreach($xml->VERSAO as $versao) { ?>
<tr>
   <td width="10%"><center> <?php echo $versao->VERTEXT ?> </center></td>
   <td width="90%"><?php echo $versao->RESUMO ?> </td>
</tr>    
<?php } ?>

It starts displaying from the first item to the last one, how do I print from last to first?

    
asked by anonymous 08.12.2016 / 20:10

1 answer

2

Make a common% of% starting from highest value for start :

Example:

$xml = simplexml_load_file('link.xml');
for($i = (count($xml->VERSAO) - 1); $i >= 0; $i--) { ?>
<tr>
   <td width="10%"><center> <?php echo $xml->VERSAO[$i]->VERTEXT ?> </center></td>
   <td width="90%"><?php echo $xml->VERSAO[$i]->RESUMO ?> </td>
</tr>    
<?php } ?>
    
08.12.2016 / 20:13