Php - to sort the arrays at one use, Array_multisort function
to sort the arrays at one use
We can sort multiple arrays based on the values of the first array at once using array_multisort function.
$a = array(c,a,d,b); $b = array(5,3,2,7);
To sort the arrays at one use
If you want array be to be sorted in ascending / descending order just use the optional args SORT_DESC, SORT_ASC.
We also have args SORT_NUMERIC, SORT_STRING to define as string and number.
<?php $a = array(c,a,d,b); $b = array(5,3,2,7); array_multisort($a, SORT_STRING, SORT_ASC, $b); print_r($a); print_r($b); ?>
Array a = a, b, c, d Array b = 3, 7, 5, 2
Now you can see that array a is sorted and values in corresponding positions of array b has also been moved.
The topic on Php - to sort the arrays at one use is posted by - Maha
Hope you have enjoyed, Php - to sort the arrays at one useThanks for your time