如何在php中只显示json中的数组值
我正在使用下面的php代码

echo '{"aaData":'.json_encode($user_details).'}';

它的输出低于
{"aaData": [
    {"id":"31","name":"Elankeeran","email":"[email protected]","activated":"0","phone":""}
]}

但我需要如下json输出
{"aaData": [
    {"31","Elankeeran","[email protected]","0","1234"}
]}

任何人请帮忙。

最佳答案

$rows = array();
foreach ($user_details as $row) {
  $rows[] = array_values((array)$row);
}

echo json_encode(array('aaData'=> $rows));

哪些输出:
{"aaData": [
    ["31","Elankeeran","[email protected]","0","1234"],
    ["33","Elan","[email protected]","1",""]
]}

08-05 01:58