开发者

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 metho开发者_Go百科d 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


It's called natural sorting: natsort() is the PHP function for it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜