tpl41803 Posted March 16, 2009 Share Posted March 16, 2009 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 More sharing options...
rhodesa Posted March 16, 2009 Share Posted March 16, 2009 are you using array_multisort() to sort the data? if so, don't forget the SORT_NUMERIC flag http://us.php.net/array_multisort Link to comment https://forums.phpfreaks.com/topic/149679-sorting-numbers/#findComment-785975 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.