Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/292.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编码值的步骤_Php_Android_Json - Fatal编程技术网

Php 解码json编码值的步骤

Php 解码json编码值的步骤,php,android,json,Php,Android,Json,上面的结果来自我尝试使用but decode方法解码的服务器,但一次又一次失败。尝试json_decode$return['return',TRUE 尝试将参数true添加为json_decode函数中的第二个参数 e、 g json_decode$json,true 使用json_decode,字符串作为第一个参数。如果在第二个参数中输入true,则返回的PHP数组将是多维的,如果没有此参数,它将是JSON对象的PHP表示 return=array(1) { ["return"]=>

上面的结果来自我尝试使用but decode方法解码的服务器,但一次又一次失败。

尝试json_decode$return['return',TRUE

尝试将参数true添加为json_decode函数中的第二个参数


e、 g json_decode$json,true

使用json_decode,字符串作为第一个参数。如果在第二个参数中输入true,则返回的PHP数组将是多维的,如果没有此参数,它将是JSON对象的PHP表示

return=array(1) {
  ["return"]=>
  string(142) "{"products":[{"pid":"1","name":"gallexy","price":"200.00","created_at":"2014-04-28 11:56:58","updated_at":"0000-00-00 00:00:00"}],"success":1}"
}

$jsonArr=json_decode$yourArray['return',TRUE@AmalMurali它给了我这个结果array2{[products]=>array1{[0]=>array5{[pid]=>string1 1[name]=>string7 gallexy[price]=>string6 200.00[created__at]=>string19 2014-04-28 11:56:58[Update_at]=>string19 0000-00-00:00:00}[success]=>int1}我非常想要像pid一样的格式,名称| gallexy-likethis@user3454782现在您有了数组格式,您可以自己设置数组的任何格式。@user3454782:这是已解码的JSON数组。现在,您可以通过访问特定索引从该数组中获取所需的值。例如,如果您想打印出键和值,只需将foreach$jsonArr['products'][0]作为$key=>$value{echo$key |$value;}
$json_decoded = json_decode($return['return'], true);

//now you can use the array

myCoolFunction($json_decoded['products']);

myCoolFunction($json_decoded['products']['pid']);