I have this complex array that I need to sort by value that is deep inside the array.
here's the array structure:
$array = array(
array(
'data' => array(
'tree_id' => 0,
'title_tag' => 'Annex A',
),
'nodes' => array(
array(
array(
'data' => array(
'tree_id' => 0,
'title_tag' => 'Annex A'
),
'attachments' => array(
'title_tag' => 'Annex A',
'updated_by' => 'Steve'
)
)
),
array(
array(
'data' => array(
'tree_id' => 0,
'title_tag' => 'Annex B'
),
'attachments' => array(
'title_tag' => 'Annex B',
'updated_by' => 'Steve'
)
)
)
)
)
);
I would like to sort the $array[ array[nodes][array][array][data]['title_tag'] ] alphabetically.
Here's what I've done so far:
foreach( $array as $arr ){
foreach( $arr['nodes'] as $node ){
foreach( $node as $data ){
$keys[] = $data['data']['title_tag'];
}
array_multisort($keys,SORT_DESC,$node);
}
}