有点像php中的facebook

有点像php中的facebook,php,facebook,sorting,facebook-graph-api,facebook-like,Php,Facebook,Sorting,Facebook Graph Api,Facebook Like,我有这个数组 {"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_coun

我有这个数组

{"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;  
}

有人能帮我吗?

你没有数组。您有一个json编码的字符串。您需要先将其json_decode()还原为本机PHP结构。我是初学者…如何对其进行json_解码?我将搜索一些教程,并在这里重新发布。谢谢你的帮助。我使用json_decode,但同样的错误…我认为排序算法有问题。你是否已将解码字符串分配给
$requests
Warning: usort() expects parameter 1 to be array, string given in C:\xampp\htdocs\test\test.php on line 35