在PHP中,我從foreach獲取數組。我是JSON編碼並一次顯示所有結果。這工作正常。但是如果我需要逐個顯示數組項目,那麼foreach仍然會繼續?在ajax中逐個顯示foreach數組項目
<?php
$array = //somearray;
$data_arr = array();
foreach($array as $arr){
//do something
$data_arr[] = $arr;
}
echo json_encode(array('success'=>true,'data'=>$data_arr));
//here i can display the data in my jquery using each function
//i can display the whole data at once after the foreach is completed
//what i need is i want to display first element of data_arr after its loop is completed and then the second element and so on
?>
,你必須 –
請提供代碼,你可以在jQuery的響應使用的每個。 –
在foreach中添加另一個foreach循環。 –