title: I have a JSON object in a file that I stored in a variable, but I can't seem to do anything I want with it because it is nested inside of an array
body: <p>My json file has contents formatted like this:</p>
  
  <pre><code>[
    {
      "id": 1,
      "keyword_filter": null,
      "name": "My Name ",
      "type": "some product",
      "sku": "1234567",
      "nested_obj": {
        "url": "http://someurl.com",
        "resource": "/orders"
      }
    }
  ]
  </code></pre>
  
  <p>I can read it into a variable like this:</p>
  
  <pre><code>$json_string = file_get_contents($jsonFile);
  </code></pre>
  
  <p>Ultimately, I need to create a tab-delimited file out of it, but I can't even seem to iterate over it.  Here's what I've tried:</p>
  
  <pre><code>foreach($json_string as $item) {
      echo $item;
  }
  </code></pre>
  
  <p>This gives me an error saying I've supplied an invalid argument in my foreach loop.</p>
  
  <p>I tried reading it into an array like this:</p>
  
  <pre><code>$json_array = file($jsonFile);
  foreach($json_array as $item) {
      echo $item;
  }
  </code></pre>
  
  <p>This echoes an array that has 1 item, which is the JSON object.</p>
  
  <p>Can someone please tell me how to get into that JSON object so I can iterate over it?
  Encoding it back into JSON just doubly escapes quotes and decoding it returns NULL.</p>
  
  <p>Any help here would be greatly appreciated... and any hints on converting to tab-delimited file would be super extraordinarily appreciated, but I'll be fine with just the first step.</p>
  
  <p>Thanks.</p>