Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.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字符串返回的输出,但我做不到_Json - Fatal编程技术网

我试图从php生成json字符串返回的输出,但我做不到

我试图从php生成json字符串返回的输出,但我做不到,json,Json,下面是我从php返回的json字符串,并建议我如何从下面的json字符串中获取值 [ { "picid": "13", "itemcode": "P-0000001", "filename": "-1970-01-011.jpg", "primarystatus": "active" }, { "picid": "16", "itemcode": "P-0000001",

下面是我从php返回的json字符串,并建议我如何从下面的json字符串中获取值

[
    {
        "picid": "13",
        "itemcode": "P-0000001",
        "filename": "-1970-01-011.jpg",
        "primarystatus": "active"
    },
    {
        "picid": "16",
        "itemcode": "P-0000001",
        "filename": "dateArray1.jpg",
        "primarystatus": "active"
    },
    {
        "picid": "18",
        "itemcode": "P-0000001",
        "filename": "dateArray3.jpg",
        "primarystatus": "active"
    },
    {
        "picid": "19",
        "itemcode": "P-0000001",
        "filename": "dateArray4.jpg",
        "primarystatus": "active"
    }
]
 //php
  function returnALLPic()
 {
    if(isset($_POST['id']))
    {
        $data= $this->m_phone->getAllPictureInformation($_POST["id"]);


    $ss= json_encode($data);
    echo $ss; 
    }

 }
//jquery $.ajax({

//log(JSONObject);//在控制台中转储对象的所有数据

             $('#model').html(msg[0].itemcode)

           }


           }); 

您可以使用以下代码解析json

var json = $.parseJSON(j);
$(json).each(function(i,val){
    $.each(val,function(k,v){
          console.log(k+" : "+ v);     
});
});

如果需要用php输出,请使用
json\u decode()

然后从循环中得到你想要的


$sss=json\u decode($data)

您也可以在PHP中执行此操作

用英语读这篇文章

$data = file_get_contents('Your_URL')
然后使用以下函数对其进行解析

$phpArray=json_decode($data)


你可以做任何你想做的事情,你的代码在哪里?我只看到一个JSON字符串你在用什么语言?你想得到什么值?它是一个对象数组。创建一个包含以上4个属性的类。看看下面的post+答案:使用$arr=JSON\U decode($JSON);我不知道如何从php获取值解析。我尝试查看其他示例,包括u,但我做不到。我是json新手。不过,感谢您的回答
$data = file_get_contents('Your_URL')