Page 1 of 1

News page

Posted: Sun Aug 31, 2003 7:26 am
by bw
Hey all,

I have a news page on my site, and it is fed by a .inc with the news articles contained in it.

How would I go about perhaps reading the file backwards for updating the page with multiple entries?

Or is there a way to write to the file in front of the data all ready there, and still keep that data?

I use a self developed system for updating the news, and it need so be ble to achieve this all automatically.

Thanks for any help,
Ben

Posted: Sun Aug 31, 2003 7:33 am
by JAM
You could, read a file using file(). The content is then inserted into an array (one row / key). array_reverse() that, and you have the opposite direction...

Code: Select all

Array
(
    [0] => 1: I'm a foo...
    [1] => 2: phpdn test...
)
Array
(
    [0] => 2: phpdn test...
    [1] => 1: I'm a foo...

)

1: I'm a foo...
2: phpdn test...

<pre>
<?php 
    $array = file('info.inc');
    print_r($array);
    $array = array_reverse($array);
    print_r($array);
    show_source('info.inc');
    show_source(__FILE__);
?>