У меня есть этот массив
{"http:\/\/test17.net46.net":{"comments":{"data":[{"id":"684775768263701_701121036629174","from":{"id":"100003109422690","name":"Buse Elena Carmina"},"message":"incercare","can_remove":false,"created_time":"2014-09-16T18:39:52+0000","like_count":2,"user_likes":false},{"id":"684775768263701_700969706644307","from":{"id":"100001307107591","name":"Theodor Nitescu"},"message":"Esti baka","can_remove":false,"created_time":"2014-09-16T12:16:34+0000","like_count":0,"user_likes":false},{"id":"684775768263701_701162809958330","from":{"id":"100000628164658","name":"Penu Oana Adriana"},"message":"comm\n","can_remove":false,"created_time":"2014-09-16T20:06:24+0000","like_count":0,"user_likes":false},{"id":"684775768263701_700979219976689","from":{"id":"100000562252107","name":"Tocu Adrian"},"message":"comm","can_remove":false,"created_time":"2014-09-16T12:49:49+0000","like_count":1,"user_likes":false},{"id":"684775768263701_701617926579485","from":{"id":"100000280451500","name":"Mihai Bogdan Ciuc\u0103"},"message":"?","can_remove":false,"created_time":"2014-09-17T18:30:18+0000","like_count":0,"user_likes":false}],"paging":{"cursors":{"after":"Mw==","before":"Nw=="}}}}}
Могу ли я отсортировать его по лайкам?
У меня есть этот код вида:
usort($requests, function($a, $b){
if ($a['user_likes']['user_likes'] == $b['user_likes']['user_likes']){
if (strtotime($a['taskuser']['created_time']) == strtotime($b['taskuser']['created_time'])){
return 0;
} else if (strtotime($a['taskuser']['created_time']) < strtotime($b['taskuser']['created_time'])){
return 1;
} else {
return -1;
}
} else if ($a['user_likes']['user_likes'] < $b['user_likes']['user_likes']){
return 1;
} else {
return -1;
}
});
но это дало эту ошибку:
Warning: usort() expects parameter 1 to be array, string given in C:\xampp\htdocs\test\test.php on line 35
Кто-нибудь может мне помочь?
Задача ещё не решена.
Других решений пока нет …