次のようなデータが与えられた場合:
$json = '[ {"value": "New", "date": "06/21/2013"}, {"value": "Open", "date": "06/20/2013"}, {"value": "Close", "date": "06/22/2013"} ]';
$array = json_decode($json, TRUE);//array of objects, so set second parameter to TRUE
usort($array, function ($a, $b){
return strtotime($a['date']) - strtotime($b['date']);
});
print_r($array);
それは配列の配列を返します。オブジェクトの配列として残し、JSON として再エンコードする場合は、次を使用できます。
$array = json_decode($json);
$ord = array_map(function($a) {return $a->date;}, $array);
array_multisort($ord, $array);
$json = json_encode($array);