PHP 에서 JSON 형식

$val = array(
        “start” => $start,
        “limit” => $board[bo_page_rows],
        “clear” => true,
        “head_name” => $board[bo_subject],
        “total” => $board[bo_count_write],
        “items” => array()
);
while ($row = sql_fetch_array($result)){
        $val[items][] = array(
            “d_idx” => $row[wr_id],
            “d_title” => $row[wr_subject],
            “d_name” => $row[wr_name],
            “d_date” => $row[wr_datetime],
            “d_view” => $row[wr_hit]
        );
}
echo json_encode($val);
————————————————————————————–

{“start”:0,”limit”:”15″,”clear”:true,”head_name”:”d”,”total”:”5″,”items”:[{“d_idx”:”8″,”d_title”:”sdfs”,”d_name”:”ucd5cuace0uad00ub9acuc790″,”d_date”:”2012-11-21 23:36:48″,”d_view”:”1″},{“d_idx”:”6″,”d_title”:”sdf”,”d_name”:”ucd5cuace0uad00ub9acuc790″,”d_date”:”2012-11-21 23:36:44″,”d_view”:”1″},{“d_idx”:”5″,”d_title”:”dsf”,”d_name”:”ucd5cuace0uad00ub9acuc790″,”d_date”:”2012-11-21 23:36:38″,”d_view”:”1″},{“d_idx”:”2″,”d_title”:”asd”,”d_name”:”ucd5cuace0uad00ub9acuc790″,”d_date”:”2012-11-19 19:09:59″,”d_view”:”6″},{“d_idx”:”1″,”d_title”:”test”,”d_name”:”ucd5cuace0uad00ub9acuc790″,”d_date”:”2012-11-19 18:31:20″,”d_view”:”7″}]}


[출처] json 형식 출력|작성자 junche4