Sorting a 5 dimensional array by date in 5th dimension value using php?

In general, you should flatten the array first, so you can sort it more easily. Once you've got the dimensionality down to a reasonable flat array of arrays with either date_added or added_date you can use usort with a function that checks for the existing key of the two and then compares them.

Here's a slightly simplified sample:

<?php
$arr = array(
  array(
    'data' => array(
      array('date_added' => 3),
      array('date_added' => 1),
      array('date_added' => 6)
    )
  ),
  array(
    'data' => array(
      array('added_date' => 4),
      array('added_date' => 0),
      array('added_date' => 5)
    )
  )
);

function normalize($arr_elem) {
  return $arr_elem['data'];
}

function sort_by_date($a, $b) {
  $dateA = array_key_exists('date_added', $a) ? $a['date_added'] : $a['added_date'];
  $dateB = array_key_exists('date_added', $b) ? $b['date_added'] : $b['added_date'];

  return $dateA > $dateB;
}

$flattened = array_reduce(array_map('normalize', $arr), 'array_merge', array());

usort($flattened, 'sort_by_date');

var_dump($flattened);
?>