简体   繁体   中英

PHP problem sorting values

I have an API returning a kind of date formatted as follow: 2010_m1 for Jan 2010 2010_m2 for Feb 2010 ... 2010_m12 for Dec 2010

I have all the dates in an array, and if I use the method sort, it will sort it like: 2010_m1, 2010_m10, 2010_m11, 2010_m12, 2010_m2, 2010_m3, ...

How could I sort it the 'correct way', ie: 2010_m1, 2010_m2, 2010_m3, ... , 2010_m10, 2010_m11, 2010_m12

Thank you

这称为自然排序natsort()是它的PHP函数。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM