PHP Reverse results

Discussion in 'PHP' started by quad_design, Aug 4, 2009.

  1. #1
    Hi,

    I'm new to php so I hope this makes sense...

    I have created a flat db for a small news section on my site, which seems to be working fine apart from the latest news always goes to the bottom.

    Is there an easy way to reverse the order that the content is printed to the screen?

    Thank you in advance for any help.

    ////////////My code


    <?php

    $db = file('includes/db/pagedata.db');
    foreach ($db as $key => $value){
    $value = trim($value);
    list($title, $news) = explode('|', $value);

    ?>

    <?php print $title; ?>
    <?php print $news ?>
     
    quad_design, Aug 4, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $db = array_reverse($db); 
    PHP:
     
    premiumscripts, Aug 4, 2009 IP
    quad_design likes this.
  3. quad_design

    quad_design Peon

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Worked, Thank you :)
     
    quad_design, Aug 4, 2009 IP