PHP Array Sort Multidimensional
PHP provides array_multisort() function to sort more than one array at a time or multi-dimensional array. String keys will be maintained but the numeric keys will be re-indexed. A little description of array_multisort() is as follows:
| General Format | bool array_multisort ( array $arr [, mixed $arg[,...]] ) |
| Parameters | arr: an array, arg: optionally another array |
| Return Value | True/False |
Example 1:
<?php
$array1
=array(10,15,2,33,69);$array2
=array(2,33,55,856,1456);array_multisort(
$array1,$array2);print_r(
$array1);echo
"<br/>";print_r(
$array2);?>
Output:
Array ( [0] => 2 [1] => 10 [2] => 15 [3] => 33 [4] => 69 ) Array ( [0] => 55 [1] => 2 [2] => 33 [3] => 856 [4] => 1456 )
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.