It sorts values in an array by columns in ascending or descending order and keeps all linked data together.
It works only with numeric or associative arrays.
If you do not mention the order then it sorts the value in ascending order.
Syntax:
array_multisort($array1, $array2);
Example:
$names = array("Riya", "Aman", "Karan");
$scores = array(90, 75, 88);
array_multisort($scores, $names);
print_r($scores);
print_r($names);
Output:
Array
(
[0] => 75
[1] => 88
[2] => 90
)
Array
(
[0] => Aman
[1] => Karan
[2] => Riya
)
