Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何进行PHP4维数组排序_Php - Fatal编程技术网

如何进行PHP4维数组排序

如何进行PHP4维数组排序,php,Php,Cassandra Json格式如下所示 "recommendResult":[{ "mediaId":"", "mediaEntry":[{ "user1":{ "name":"sooin", "rating":"3", "views":"2", "like":"ture", "comme

Cassandra Json格式如下所示

    "recommendResult":[{
       "mediaId":"",
       "mediaEntry":[{
           "user1":{
               "name":"sooin",
               "rating":"3",
               "views":"2",
               "like":"ture",
               "comment":"good"
           },
           "user2":{
               "name":"sara",
               "rating":"1",
               "views":"4",
               "like":"ture",
               "comment":"good!"
           }
       }],
       "view":"4",
       "rating":"4",
       "like":"10",
       "smallUrl":"/photo/smallUrl",
       "largeUrl":"/photo/largeUrl",      
       "title":"aaaa"                  
    }]
这是我的php代码

$rows=$column_family->get_range();
$count=0;

    foreach($rows as $key => $columns) {

     $returnkey[$count]=array('mediaId'=>$key,   
              'columns'=>$columns,'user'=>array_slice($columns,1,2));
     $count++;
}
natcasesort($returnArray['key']['comment']['photoInfo']['view']);
print_r($returnArray['key']['comment']['photoInfo']['view']);
我正在尝试根据视图进行排序。 我尝试使用natcasesort,但它不起作用。 有什么想法吗。
谢谢。

PHP没有内置的排序算法,可以根据特定的键/值对对多维数组进行排序。您应该编写自己的排序算法来处理这些数据

这里是开始的地方(所有这些都可以很容易地修改以使用特定阵列):