Alicia Posted January 23, 2010 Share Posted January 23, 2010 Hi guys, I am trying to figure out the easiest way for me to re-arrange a number assigned and I hope can get some advise from gurus. A user will post a number such as 3416 and I want to have a function to re-arrange it with options Option A) from smallest number to largest - 1346 and Option B) from largest to smallest - 6431 other example is like = number posted by user : 761 , output will be as below Option A) 167 Option B) 761 I am thinking to split the numbers posted into array for each digit but how can i re-position the split numbers to the order as required in optionA and B ? Any predefined array function I can use to sort the numbers in such a way? Please advise and thanks. Link to comment https://forums.phpfreaks.com/topic/189545-re-arrage-numbers/ Share on other sites More sharing options...
Mchl Posted January 23, 2010 Share Posted January 23, 2010 sort and rsort Link to comment https://forums.phpfreaks.com/topic/189545-re-arrage-numbers/#findComment-1000478 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.