PHP array sorting sort, asort, and Ksort usage

Source: Internet
Author: User
Tags array sort

Share the sort, asort, and ksort usages of the PHP array, which is a simple example of the use of sort, asort, and Ksort, with comments detailing them.

The use of sort, asort, and Ksort in the ordering of PHP arrays.

<? PHP $arr Array (' d ' = ' sdf ', ' r ' = ' sdf ', ' a ' = ' eee '); // sort ($arr);//The value of the array is re-//asort, the previous key value is deleted, and the index array is changed to the indexed arrays ($arr);//The array is re-sorted by value, and the index relationship is maintained, and the indexed and associative arrays apply Ksort ($arr// arrays are re-sorted by key value and maintain index relationships, indexed arrays and associative arrays apply//correspond to reverse order and Rsort Arsort krsort//use function compare Usort Uksort Uasort the second parameter for the comparison function needs to return a value equal to less than 0 when the first parameter equals less than the second argument, and the floating-point number will only take the integer part //www.jbxue.comprint_r($arr );? >

In this example, only ksort usage is demonstrated, and you can test the results of sort and asort in order to deepen your impressions and grasp them firmly.

Sorting the PHP array sort, asort, and Ksort usage

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.