An array is sorted in the order of another array element

Source: Internet
Author: User
Keywords PHP Array sort

The words are always so pale,

The first array is the one that gets the id array, and it's already sorted.
But the order of the data key values obtained below has been messed up. foreachHow to sort gracefully when not in use, with the same result as the first array order
Want to get the results like this

    [        131 => array(),        89 => array(),        141 => array(),        43 => array(),        140 => array(),    ]

Reply content:

The words are always so pale,

The first array is the one that gets the id array, and it's already sorted.
But the order of the data key values obtained below has been messed up. foreachHow to sort gracefully when not in use, with the same result as the first array order
Want to get the results like this

    [        131 => array(),        89 => array(),        141 => array(),        43 => array(),        140 => array(),    ]

Isn't it nice to use foreach, and the view isn't just a foreach traversal? You can not deal with that. Cases

$this->view->assign('indexArray', $indexArray);$this->view->assign('dataArray', $dataArray);//--viewforeach ($indexArray as $id) {    print_r($dataArray[$id]); //对不对?}
  • 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.