Php extracts some characters from the array and sorts them by characters

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.