我在将数据json转换为数组时遇到了问题。
我的代码
$url = "http://pondokprogrammer.com/image.php";
// Initiate curl
$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$url);
// Execute
$result=curl_exec($ch);
// Closing
curl_close($ch);
$decode = json_decode($result);
echo "<pre>".print_r($decode,1)."</pre>";
像这样的json数据
[
{
submit_time: "1433919003.5213"
},
{
submit_time: "1433940260.0048"
}
]
当我运行返回的NULL或数据没有显示任何内容时,我已尝试使用
trim ();
stripslashes ();
mb_convert_encoding ($ result, 'UTF-8', 'UTF-8');
当我运行时总是返回NULL,结果相同 任何人都可以帮助我......? 谢谢
答案 0 :(得分:0)
您的链接http://pondokprogrammer.com/image.php
正在回显使用<pre>
格式化的PHP数组。您需要在echo json_encode($array)
image.php