read .xml files in reverse order

1

I am generating the reading and writing of files .xml via php, the problem is that they appear from the first to the last one and I want the last ones to be added to be the first to appear.

Here is the code:

<?php
        for ($i = 1; $i <= $conta; $i++) {
            $usuario = simplexml_load_file('xml/' . $i . '.xml');
            echo '<div style="background-color:#F6A6A6;width:800px;height:200px;border-radius:50px;margin-top:10px;">';
            echo '<div style="color:white;"><br>';
            echo '<label style="float:bottom;float:left;padding-left:40px;font-family: Dancing Script, cursive;font-size:20px;color:black">Nombre: &nbsp</label>';
            echo '<label style="font-family: Courgette, cursive;font-size:16px;">';
            echo $usuario->Tiempo[0]->nombre;
            echo '</label>';
            echo '</div>';


            echo '<div style="color:white;"><br>';
            echo '<label style="float:bottom;float:left;padding-left:40px;font-family: Dancing Script, cursive;font-size:20px;color:black">E-mail: &nbsp</label>';
            echo '<label style="font-family: Courgette, cursive;font-size:16px;">';
            echo $usuario->Tiempo[0]->correo;
            echo '</label>';
            echo '</div>';
            echo '<div style="color:white;"><br>';
            echo '<label style="float:bottom;float:left;padding-left:40px;font-family: Dancing Script, cursive;font-size:20px;color:black">Mensaje: &nbsp</label>';
            echo '<label style="font-family: Courgette, cursive;font-size:16px;">';
            echo $usuario->Tiempo[0]->mensaje;
            echo '</label>';
            echo '</div>';
            echo '</div><br><br>';
        }
        ?>
    
asked by David 05.06.2016 в 21:33
source

1 answer

3

Right now the loop for that shows the comments / messages goes from 1 to $conta , a possible solution to show them in reverse order would be to make the loop for go from $conta to 1:

for ($i = $conta; $i >= 1; $i--) {
    // el resto de tu código se mantiene igual
    
answered by 05.06.2016 / 23:58
source