$method($request); // Convert array to JSON if(is_array($result)) { header('Content-Type: application/json'); $result = json_encode($result); } echo $result;