0

从下图可以看出,我只在前端返回了一行。我应该得到不止一排返回。有人知道我做错了什么吗?

在此处输入图像描述

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));
    }
4

1 回答 1

4

也许你想要:echo json_encode(array($imUsers));

$imUsers 没有 $imUser ?

于 2012-12-26T17:03:34.273 回答