Skip to content

Instantly share code, notes, and snippets.

@codescribblr
Created February 13, 2014 21:41
Show Gist options
  • Select an option

  • Save codescribblr/8984458 to your computer and use it in GitHub Desktop.

Select an option

Save codescribblr/8984458 to your computer and use it in GitHub Desktop.
Sort multidimensional array
<?php
$transactions = array(
0 => array('date'=>1324235252, 'day'=>'monday'),
1 => array('date'=>1326516552, 'day'=>'tuesday'),
2 => array('date'=>1333453235, 'day'=>'wednesday')
)
function sortByOrder($a, $b) {
return $b['date'] - $a['date'];
}
usort($transactions, 'sortByOrder');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment