model = new Post(); } public function posts() { $get = []; $get['count'] = 0; $get['data'] = $this->model->showJoin([ ['pengumuman.status', '=', 1] ]); if (array_key_exists(0, $get['data']) == false) { $temp_data = $get['data']; unset($get['data']); $get['data'][] = $temp_data; $temp_data = []; } if ($get['data'] != false) { $get['count'] = count($get['data']); } header('Content-Type: application/json'); echo json_encode($get); } }