arrays - Sort JSON data based on UTC timestamp in php from client side -
i have json data. 1 of fields timestamp. there way sort data based on timestamp? please don't recommend me jquery plugins datatables. , don't want fetch data database in sorted order either. use following sql command.
select * tablename;   i don't want data in sorted form database using command this.
select * tablename order by.....   is possible sort json data i've said using php??? want data sorted in descending order based on timestamp. suggestions???
here sample data
http://codepad.viper-7.com/tylowv
i tried this...
function sortbyyear($a, $b) {     $da = new datetime($a['date']);     $db = new datetime($b['date']);      return $da->format('y') - $db->format('y'); }   $d = json_decode($sample_data, true); $info = $d['date'];  usort($info, 'sortbyyear');  print_r($info);      
try array_multisort function in php
$date = array(); $d = json_decode($sample_data, true); foreach ($d $key => $row) {     $date[$key] = $row['date']; } array_multisort($date, sort_desc, $d);      
Comments
Post a Comment