我想将我的文件转换为json decode。之后我想得到数组格式。如果我改为数组,则输出为Array [0] =&gt; null。我该怎么办?< /强> 这是我的文件
{
"status": "1",
"mobile_user": [
{
"id": "1",
"name": "saa",
"phone_no": "09978784963",
"activate_code": "",
"deposit": "0",
"created": "2015-05-29 00:00:00",
"updated": "0000-00-00 00:00:00",
"status": "1"
},
{
"id": "3",
"name": "ttr",
"phone_no": "090930499",
"activate_code": "",
"deposit": "0",
"created": "2015-06-01 00`:00:00",
"updated": "0000-00-00 00:00:00",
"status": "0"
},.....
这是我的代码
<?php
include "connect.php";
$data = file_get_contents("http://192.168.0.100/busexpress/api/v1/mobile_user_register/mobile_user_register/retrieve.json");
$json =array(json_decode($data, true));
print_r ($json);
?>
答案 0 :(得分:0)
这对我有用。你确定你有一个有效的json文件路径吗?您是否有任何错误显示?
答案 1 :(得分:-1)
我尝试了你的代码,我认为远程文件没有响应。这就是我得到的。否则代码对我来说很好。
Warning: file_get_contents(http://192.168.0.100/busexpress/api/v1/mobile_user_register/mobile_user_register/retrieve.json): failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time or established connection failed because connected host has failed to respond.
数组([0] =&gt;)