接口数据转json格式

function tojson($result, $callback = null){
        header('Content-Type:text/html; charset=utf-8');
        $json_result = urldecode(json_encode($result));

        if (empty($callback)) {
            echo $json_result;
        } else {
            echo $callback . "($json_result)";
        }
        die();
    }

 

posted on 2019-06-21 09:58  夏沫忆香  阅读(1183)  评论(0编辑  收藏  举报