Skip to content

Instantly share code, notes, and snippets.

@tobiastom
Created October 13, 2009 08:38
Show Gist options
  • Save tobiastom/209107 to your computer and use it in GitHub Desktop.
Save tobiastom/209107 to your computer and use it in GitHub Desktop.
<?php
$array[0]["name"]="test";
$array[0]["datum"]="10.1.2010";
$array[1]["name"]="test1";
$array[1]["datum"]="10.1.2009";
$array[2]["name"]="test2";
$array[2]["datum"]="10.1.2011";
function my_sort($itemA, $itemB) {
$datumA = strtotime($itemA['datum']);
$datumB = strtotime($itemB['datum']);
if ($datumA == $datumB) {
return 0;
}
return $datumA > $datumB ? 1 : -1;
}
usort($array, 'my_sort');
var_dump($array);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment