Php extracts some characters from the array and sorts them according to the characters. assume there is an array $ a & nbsp; array (2013aaa, 2011bb, 2015c ); in fact, this prime group is obtained from the database. the format is the first four words and four digits. I want to sort by 2013.2011.2015. The result is: 2011bb, 2013aaa, and 5C 5C. I don't know how to implement this? Php extracts some characters from the array and sorts them by characters
Suppose there is an array $ a = array ("2013aaa", "2011bb", "2015c ");
In fact, this prime group is obtained from the database. the format is the first four words and four digits.
I want to sort by 2013.2011.2015. The result is as follows:
2011bb, 2013aaa, 2015c
I don't know how to implement this?
Share: More
------ Solution --------------------
Isn't the direct order by field asc enough?
------ Solution --------------------
$ A = array ("2013aaa", "2011bb", "2015c ");
Sort ($ );
Print_r ($ );
Array
(
[0] => 2011bb
[1] => 2013aaa
[2] => 2015c
)
------ Solution --------------------
After the problem is solved, paste it.