从下面的图片可以看出,我只在前端找到一排。我应该返回多行。有人知道我做错了吗?
public function chatBoxMembers() {
$userid = $this->session->userdata('userid');
$wow = $this->db->get_where('messages', array('messageRecipientId' => $userid));
foreach($wow->result() as $row) {
$imUser = array();
$imUser['friendId'] = $row->messageSentById;
$imUser['messageBody'] = $row->messageBody;
$imUser['readStatus'] = $row->readStatus;
$imUser['activityStatus'] = $row->activityStatus;
$imUsers[] = $imUser;
} echo json_encode(array($imUser));
}
答案 0 :(得分:4)
也许你想要: echo json_encode(array($ imUsers));
$ imUsers no $ imUser?