如何在php中正确编写它?json

如何在php中正确编写它?json,php,json,Php,Json,如何在php中回显json?服务器向我发送json $i=$_POST["id"]; if($i==1){ // here i must echo this { "item": { "html": [{ "description": "some text", "n": "1" }], "table": { "1": { "line": [{

如何在php中回显json?服务器向我发送json

$i=$_POST["id"];
if($i==1){

// here i must echo this

{

"item": 

{
        "html": 
[{

"description": "some text",
            "n": "1"
        }],
        "table": {

            "1": {

                "line": [{

                    "number": "",

                    "value": ""

                }

                ]
            }

        },
        "videos": [],

        "urlext": [],

        "imgs": [ {

            "size": {

                "root": "xxx xxx"

            }

        }]

    }

}


}
else {

// here i must echo another one

{

"item": 

{
        "html": 
[{

"description": "some text",
            "n": "1"
        }],
        "table": {

            "1": {

                "line": [{

                    "number": "",

                    "value": ""

                }

                ]
            }

        },
        "videos": [],

        "urlext": [],

        "imgs": [ {

            "size": {

                "root": "xxx xxx"

            }

        }]

    }

}


}


} 

只需构建一个需要作为json发送的数据的关联数组,并使用
json\u encode()
呈现json

$data = array( 'name' => 'foo',
               'some' => 'thing' 
);

echo json_encode($data);

echo json_encode($yourContent);。你怎么没有在谷歌上找到这一点,或者甚至没有在这个网站上搜索到这一点呢???因此,这些天来,人们不断地提出一些问题,表明他们没有进行任何研究。。至少是PHP问题