简体   繁体   中英

to get array format if convert json code in php

I want to convert my file into json decode.After that I want to get with array format.If I change to array ,output is Array[0]=>null.How can I do that? This is my file

{
  "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"
    },.....

This is my code

 <?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);      

    ?>

It is working for me. Are you sure you have a valid path of json file? Do you have any error that displayed?

i tried your code, I think the remote file is not responding. Here is what I got. otherwise the code looks fine to me.

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.

Array ( [0] => )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM