About php sort function array_multisort uses one function to sort another function

The array function array_multisort () in PHP is actually very powerful. Here I will only say that one of the usages is how to use one array to sort another array.

array_multisort ($ arr1, $ arr2);
First, the number of elements in the $ arr1 and $ arr2 arrays must be the same, where $ arr1 is the sorting array to be referenced and $ arr2 is the array to be sorted. The $ arr1 array can be an unordered one-dimensional array.

$arr1 = [4,3,2,5,1];
$arr2 = ['a','b','c','d','e']

array_multisort($arr1,  $arr2, SORT_REGULAR );

结果:
$arr1 = [1,2,3,4,5];
$arr2 = ['e','c','b','a','d'];

Guess you like

Origin blog.51cto.com/11016194/2487954