Or [about sorting php arrays ?]

Source: Internet
Author: User
Or [about sorting php arrays ?] Sorry, it should be the problem I described. I am also confused when the moderator does not see it.
Http://bbs.csdn.net/topics/390595473? Page = 1 # post-395606907

$ Arr = array ('zhong', 'qiu', 'hangzhou', 'kuai', 'le ')


Actually, I want the effect that the moderator program has come out, but the difference is that the moderator program starts with "medium, the effect I want is that the previous words can also be reduced:
For example, there is such sorting (in red)
Happy Mid-Autumn Festival
Fast Mid-Autumn Festival
Mid-Autumn Festival
Mid-Autumn Festival
Fast Autumn Festival
Autumn Festival
Jiule
Mid-Autumn Festival
Medium
Autumn

Finally, it is better to be an array ~


I just wanted to use the program provided by the moderator in the previous post, but I am not a professional programmer. I just started learning and cannot understand it. I have to help you again. thank you.


Reply to discussion (solution)

What is the basis for reduction?
Why is happy holidays not here?

After executing the code, remove the first element of the array and execute it again.
Isn't it all "autumn "?

What is the basis for reduction?
Why is happy holidays not here?

After executing the code, remove the first element of the array and execute it again.
Isn't it all "autumn "?

Sorry, I have not described it clearly.

The basis for the reduction is to reduce the numbers in sequence, which is to sort all the values except the order.
There should be [happy holidays] The columns listed above are not fully written. sorry. Cause misunderstanding.

$ Arr = array ('zhong', 'qiu', 'hangzhou', 'kuai', 'le'); $ res = array (); for ($ j = 0; $ j
 
  
Array
  
(
[0] => Happy Mid-Autumn Festival
[1] => Happy Autumn Festival
[2] => Fast Mid-Autumn Festival
[3] => Mid-Autumn Festival
[4] => Happy Holidays
[5] => Fast Autumn Festival
[6] => autumn festival
[7] => Mid-Autumn Festival
[8] => Fast Mid-Autumn Festival
[9] => Zhongqiu le
[10] => Fast
[11] => Music Festival
[12] => Happy
[13] => autumn festival
[14] => Fast autumn
[15] => Qiu Le
[16] => middle section
[17] => Fast
[18] => Zhongle
[19] => Mid-Autumn Festival
[20] => section
[21] => Fast
[22] => Happy
[23] => autumn
[24] => Medium
)

$ Arr = array ('zhong', 'qiu', 'hangzhou', 'kuai', 'le ')


Implementation:
Happy Mid-Autumn Festival
Fast Mid-Autumn Festival
Mid-Autumn Festival
Mid-Autumn Festival
Fast Mid-Autumn Festival
Zhongqiu le
Mid-Autumn Festival
Section
Moderate fast
Zhongle
Medium
Autumn
Section
Fast
Happy


Happy Autumn Festival
Fast Autumn Festival
Autumn Festival
Autumn Festival
Autumn fast
Qiu Le


Happy Holidays
Fast
Jiule

Happy


The result is preferably sorted by the number of words, from many to few.

Thanks for choosing the moderator.

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.