k0z Posted September 4, 2009 Share Posted September 4, 2009 If i have: $stats=3; $favorites=2; $uploads=4; $recent=1; How can I create an output that puts these items in order (by number)? E.g. for this case, the output would return: "recent:favorites:stats:uploads" as a text string. Thanks. Link to comment https://forums.phpfreaks.com/topic/173048-data-ordering-question/ Share on other sites More sharing options...
BinaryG Posted September 4, 2009 Share Posted September 4, 2009 The best way i could think of right now is put them in an array with keys and then use sort() to arrange them then echo them out this should help http://www.w3schools.com/php/func_array_sort.asp if you need more help just say Link to comment https://forums.phpfreaks.com/topic/173048-data-ordering-question/#findComment-912112 Share on other sites More sharing options...
k0z Posted September 4, 2009 Author Share Posted September 4, 2009 Not sure how to implement this. Can I get an example? Link to comment https://forums.phpfreaks.com/topic/173048-data-ordering-question/#findComment-912117 Share on other sites More sharing options...
anatak Posted September 4, 2009 Share Posted September 4, 2009 http://jp2.php.net/manual/en/language.types.array.php $ar_var_name=(array"stats"=>3, "favorites"=>2, "uploads" .... ) if you want to print some var you do echo $ar_var_name["stats"] output = 3 Link to comment https://forums.phpfreaks.com/topic/173048-data-ordering-question/#findComment-912121 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.