Jump to content

[SOLVED] Max value from a file


liamthebof

Recommended Posts

Hello.

 

I have a file like so:

 

freddy,382372
bobby,2312
georgy,32456
franky,48278

 

I now need to read this file, and output the names and values in descending order but only the top 3, ie

freddy = $382372
franky = $48278
georgy = $32456

 

Dont worry about the =$, I can do that. Also, the file can be chnage however you like, aslong as a name and value is on each line, eg. '382372 - freddy' as I actually write the file in a previous script which can be edited.

 

So, how can I ouput the data in dessceding order from the data give in the file. I was thinking looping max() and pregmatchign but I think im way off mark.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/121463-solved-max-value-from-a-file/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.