In following PHP code in here //print_r($reunits);
is output this: http://pastebin.com/RbqZ5kHV
but in here echo json_encode($reunits);
is output as: http://pastebin.com/GFdHkg5Y
If use $reunits = array('reunits'=>$units_data);
as: $reunits .=...
i get this output in echo json_encode($reunits);
: "ArrayArrayArray"
Hoe kan output zoals output worden geplaatst in //print_r ($ reunits);
op output echo json_encode ($ reunits);
? Hoe kan het oplossen?
$reunits = "";
//$tourf_id = $this->input->post('tour_name');
$tourf_id = '102';
//$query_r = $this->db->order_by('id','desc')->get_where('tour_foreign_residence', array('relation' => $tourf_id));
$query_r = array('77192276', '15190364', '15183965')
foreach($query_r->result() as $idx=>$val){
$hotel_id = $val->hotel_id;
$query = $this->db->get_where('tour_foreign_units', array('hotel_id' => $hotel_id));
$units_data = array();
foreach ($query->result() as $index=>$row) {
$units_data[] = array(
'name' => $row->name,
'price' => $row->price,
'extra' => $row->extra,
'hotel_id' => $row->hotel_id
);
}
$reunits = array('reunits'=>$units_data);
//print_r($reunits);
}
echo json_encode($reunits);
Deze uitvoer wordt door json_encode naar ajax-aanroep in jQuery verzonden.