I need a PHP script which would sort an array of numbers by first digit, then by second digit, and so on.
For example, an array:
$arr = array(1, 94, 4, 925, 401, 277, 255);
should result in a sort like this:
1,
255,
277,
4,
401,
925,
94
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Sort it as strings, by passing
SORT_STRINGto thesort()function:This outputs: