I have a nested array so a number of nodes, each with a child array of a number of further nodes. One of these child nodes is a date (in yyyymmdd format), so something like:
Code: Select all
Array
(
[0] => Array
(
[date] => 20100501
[value2] => South
[value3] => 7
)
[1] => Array
(
[date] => 20100424
[value2] => North
[value3] => 7
)
...Code: Select all
foreach($masterArray as $childArray)
{
$sortByDate[] = $childArray['date'];
}
$success = array_multisort($sortByDate, SORT_ASC, $masterArray);
print_r($masterArray);Code: Select all
foreach($masterArray as $childArray)
{
$sortByDate[] = $childArray;
}
print_r($sortByDate);So I am at a loss to see how I end up in the second example with a sorted array. There is no array indexing going on in the foreach loop that would result in the recordering of the array. Quite what am I doing? I cannot see how I am building a sorted array!