sorting problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Canabalooza
Forum Newbie
Posts: 5
Joined: Sat Aug 09, 2003 11:08 am

sorting problem

Post 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.
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post 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...
Canabalooza
Forum Newbie
Posts: 5
Joined: Sat Aug 09, 2003 11:08 am

Post by Canabalooza »

Hey thanks a bunch. Now I know where to go if I need help again.
Post Reply