Jump to content

re-arrage numbers?


Alicia

Recommended Posts

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

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.