Using php 5.3, I am trying to sort the arrays descending. I have the following multiple single arrays after a string explode:
Array
(
[0] => A
[1] => 115
[2] => 20
)
Array
(
[0] => A
[1] => 140
[2] => 50
)
Array
(
[0] => A
[1] => 120
[2] => 40
)
The output I am looking for would be to sort ascending by key[1]
so it will look like this:
Array
(
[0] => A
[1] => 115
[2] => 20
)
Array
(
[0] => A
[1] => 120
[2] => 40
)
Array
(
[0] => A
[1] => 140
[2] => 50
)
The code I have so far is :
$data = string_content_to_explode
foreach($data as $line) {
if(substr($line,0,1)=="A") {
$parts = explode(chr(9), $line);
// sort awards DESC
array_multisort($parts[1]);
}
echo "<pre>"; print_r($parts); echo "</pre>";
Unfortunately this has no effect whatsoever. I can not find a function or example of a foreach which can sort multiple single arrays in this way. If someone can point me in the right direction that would be great.