Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,094 questions

40,775 answers

573 users

How to sort an array of numeric strings in ascending order with PHP

2 Answers

0 votes
$array = array("7", "0", "55", "8", "9", "6");

sort($array, SORT_NATURAL);

print_r($array);




/*
run:

Array
(
    [0] => 0
    [1] => 6
    [2] => 7
    [3] => 8
    [4] => 9
    [5] => 55
)

*/

 





answered Sep 2, 2022 by avibootz
0 votes
$array = array("7", "0", "55", "8", "9", "6");

natsort($array);

print_r($array);




/*
run:

Array
(
    [0] => 0
    [1] => 6
    [2] => 7
    [3] => 8
    [4] => 9
    [5] => 55
)

*/

 





answered Sep 2, 2022 by avibootz
...