Jump to content

sorting numbers


tpl41803

Recommended Posts

Just a quick question -- I have a very nice php script that sorts info from my flat-file db in different ways

 

by name, year, price, model, etc...

 

I've started to notice that my code isn't sorting the information correctly by my price field--everything alphabetical sorts properly, and the short number columns sort right (year, for example) but the price doesn't work

 

        if ($sortby == 'title') $sortkey = strtolower($title);
if ($sortby == 'year') $sortkey = $year;
if ($sortby == 'price') $sortkey = $price;

 

that's the bit of my code that's being problematic--i'm wondering if there's maybe there's a function that sorts this correctly -- or perhaps i need to strip the dollar signs away in order to make it work right.

 

i don't know THAT much about php, i'm really teaching myself so any suggestions would be greatly appreciated,

 

thanks!

Link to comment
https://forums.phpfreaks.com/topic/149679-sorting-numbers/
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.