PHP Warning:array_multisort (): Array sizes is inconsistent

Source: Internet
Author: User
Tags sorts

The Array_multisort () function returns a sorted array. You can enter one or more arrays. The function first sorts the first array, then the other arrays, and if two or more values are the same, it sorts the next array.


Encountered this error is caused by two array contrast inconsistency,


If a one-dimensional array is sorted with a two-dimensional array, it can be resolved in the following ways:

Using this method, it would be more troublesome to extract the age to be stored in a one-dimensional array, and then in ascending order. The specific code is as follows:


Copy the Code code as follows:


$ages = Array ();
foreach ($users as $user) {
$ages [] = $user [' Age '];
}


Array_multisort ($ages, SORT_ASC, $users);


This article is from the "12380959" blog, please be sure to keep this source http://12390959.blog.51cto.com/12380959/1966839

PHP Warning:array_multisort (): Array sizes is inconsistent

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.