As you can tell from the image below I’m only getting one row back in the frontend. I should be getting more than one row returned. Does anybody know what I am doing wrong?

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));
}
Maybe you want: echo json_encode(array($imUsers));
$imUsers no $imUser ?