Page 1 of 1

sorting problem

Posted: Sat Aug 09, 2003 11:08 am
by Canabalooza
I have a script that enters data into a text file and then pulls it out to display it. For example I have two guys names, Dave and peter. in the text file Dave is on the first line and peter is second. When I call the function with,

function showlinks() {
global $filename;
$html = implode(array_reverse(file($filename)));
print $html;
}

It displays them on the page as Peter first then Dave second. I don't know that much php so to change it so that it will sort it the other way I have no clue how to do. If anyone can help I would greatly appreciate it. Thanks in advance.

Posted: Sat Aug 09, 2003 11:24 am
by Stoker
if the file is always sorted you simply need to remove the array_reverse() , if the file isnt always sorted you can replace it with array_sort instead...

Posted: Sat Aug 09, 2003 1:17 pm
by Canabalooza
Hey thanks a bunch. Now I know where to go if I need help again.