Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在json响应中添加html_Php_Jquery_Json - Fatal编程技术网

Php 在json响应中添加html

Php 在json响应中添加html,php,jquery,json,Php,Jquery,Json,我从一个sql查询中获取json,如下所示: $zips[$i] = "{\"type\" : \"Feature\",\"properties\": { \"name\" : \"{$row["Name"]}\"},{$row["RegionCenterGeoJSON"]}}"; {"name" : “<span id=’map_label’>77060</span>” $(‘#map_label’).each(function() {

我从一个sql查询中获取json,如下所示:

    $zips[$i] = "{\"type\" : \"Feature\",\"properties\": { \"name\" : \"{$row["Name"]}\"},{$row["RegionCenterGeoJSON"]}}";
    {"name" : “<span id=’map_label’>77060</span>”
   $(‘#map_label’).each(function() {
            $(this).css(‘font-size’, ‘20px’);
其中Name返回的邮政编码如下:

    {"name" : "77002"} //with the rest of the response around it
在json中。我需要做的不是邮政编码,而是像这样的东西:

    $zips[$i] = "{\"type\" : \"Feature\",\"properties\": { \"name\" : \"{$row["Name"]}\"},{$row["RegionCenterGeoJSON"]}}";
    {"name" : “<span id=’map_label’>77060</span>”
   $(‘#map_label’).each(function() {
            $(this).css(‘font-size’, ‘20px’);
}

我以前做过这件事,但是我有一个json项目,并且手动将zip更改为我所需要的,但是现在我想在代码中使用数百个json项目。在php中有这样做的方法吗?我试着这么做:

   {$row["<span id = 'map_label'>"'Name'"</span>" ]}

但是如果运气不好

你会有什么错误吗?另外,你能在现在发送的时候发布完整的json吗?你在找{.$row[Name].]}?我可能没有正确的引语。另外,看起来您正在通过字符串连接生成json。。。不要这样做,使用数组和json_encode。为什么不使用$。每个来迭代数组或对象,然后在客户端添加标记。我有一个正常工作的php,它返回正确且有效的json,我只想在邮政编码周围添加跨度,以便我可以在html/javascript中使用它。我应该提到的是,我将此用于GeoJson。我寻找的结果是{name:“77060”},其中77060是邮政编码,我只是在json中添加HTML内容