PHP simple multi-dimensional array merging and sorting function example, multi-dimensional sorting Function

Source: Internet
Author: User

PHP simple multi-dimensional array merging and sorting function example, multi-dimensional sorting Function

This example describes how PHP can merge and sort multi-dimensional arrays. We will share this with you for your reference. The details are as follows:

<? Php $ record = array ('title' => 'This is the title, the first array', 'description' => 'descriptive content ', 'picurl' => 'photo link ', 'url' => 'link', 'juli' => 34 ); $ record_other = array ('title' => 'This is the title, the second array', 'description' => 'descriptive content ', 'picurl' => 'photo link', 'url' => 'link', 'juli' => 14); // merge the array $ re = array_merge ($ record, $ record_other); // sort in ascending order by the "juli" field $ juli_sort = array (); foreach ($ re as $ arr2) {$ juli_sort [] = $ arr2 ['juli'];} array_multisort ($ juli_so Rt, SORT_ASC, $ re); var_dump ($ re);?>

Running result:

Array (5) {["juli"] => int (14) ["url"] => string (4) "Link" ["description"] => string (8) "description" ["picurl"] => string (10) "photo link" ["title"] => string (24) "This is the title, the second array "}

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.