For example i have an array named $slice like this :
Array
(
[0] => Array
(
[0] => 12
[1] => 4
[2] => 2
[3] => 8
[4] => 20
)
[1] => Array
(
[0] => 9
[1] => 7
[2] => 1
[3] => 10
[4] => 23
)
)
I want to sort array above so the output will be like this :
Array
(
[0] => Array
(
[0] => 2
[1] => 4
[2] => 8
[3] => 12
[4] => 20
)
[1] => Array
(
[0] => 1
[1] => 7
[2] => 9
[3] => 10
[4] => 23
)
)
Then i tried to use foreach and array_multisort, and when i use print_r the result is 1 for each col :
foreach ($slice1 as $col) {
$slicesort[] = array_multisort($col);
}
output :
Array
(
[0] => 1
[1] => 1
)
array_multisort()can be used to sort several arrays at once, or a multi-dimensional array by one or more dimensions. You're not sorting a multi-dimensional array; you're sorting elements of a multidimensional array.