PHP Warning: array_multisort (): Array sizes are inconsistent
The array_multisort() function returns a sorted array. You can enter one or more arrays. Function sorts the first array, then the other arrays, and if two or more values are the same, it sorts the next array.
Encounter this error is caused by the inconsistency of the two arrays,
If it is a one-dimensional array and two-dimensional array sorting can be solved by the following method:
Using this method, it will be more troublesome to extract the age and store it in a one-dimensional array, and then arrange it in ascending order of age. The specific codes are as follows:
The copy code is as follows:
$ages = array();
foreach ($users as $user) {
$ages[] = $user['age'];
}
array_multisort($ages, SORT_ASC, $users);