json 스타일 전환

   public function bbb(){
        header("content-type:application/json,charset=utf-8");//*
        $url="http://zphteach.com/zph/8wei/json/json.php";
        $file=file_get_contents($url);
        $b=json_decode($file,true);
        //print_r($b);die;
        $b[0]['name']="zhangsan's";

        $b[1]['name']="lisi<zhangsan";


        header("content-type:application/xml");//*
        //print_r($b);die;
        echo '<?xml version="1.0" encoding="utf-8" ?>';
        echo "<note>";
        foreach($b as $key => $val){
            echo "<rows>";
                foreach($val as $k => $v){
                    echo "<a>";
                    echo $v;
                    echo "</a>";
                }
            echo "</rows>";
        }
        echo '</note>';
    }

좋은 웹페이지 즐겨찾기