我有显示TripUUID
的代码。但是它只显示一个数据。代码如下:
function list_of_tripreview(){
$data = $this->data;
$arr = [];
$data['list_of_tripreview'] = $this->cms_model->list_of_tripreview();
$TripUUID = $data['list_of_tripreview'][0]['TripUUID'];
echo json_encode($TripUUID);
此代码在索引TripUUID
上给出输出0
。如何修改此程序以显示不带[{0
]的所有索引数据?
答案 0 :(得分:1)
您可以使用 foreach loop
$data['list_of_tripreview'] = $this->cms_model->list_of_tripreview();
$datas = $data['list_of_tripreview'];
//$TripUUID = $data['list_of_tripreview'][0]['TripUUID'];
foreach($datas as $key => $item){
echo $item['TripUUID'].'<br>';
}