I'm trying to sort an array of strings numerically in php. Each string beginns with a number.
The content of the array looks like this:
1_some-str
2_some-str
3_some-str
4_some-str
...
10_some-str
11_some-str
With sort() the output is like this:
10_some-str
11_some-str
1_some-str
2_some-str
...
9_some-str
How can I achive, that the array gets sorted upwards from from 1-11?
Edit:
natsort() did not work.
sort($array, SORT_NUMERIC) did the job! Thanks.
natsort: php.net/manual/en/function.natsort.php