php - Decoding JSON array -


I'm trying to parse a simple JSON array, trying to figure out.

Here is the data:

  {"data": [{"name": "john", "id": "123"}, {"name": "Dave", "id": "345"}, "other": {"foo": "bar"}}  

I need only data information .

Here is what I am trying to do (and also what I tried):

  $ list = json_decode (file_get_contents ($ jsonURL), true); Forex Currency ($ Element $ as element) {// $ id = $ element- & gt; Data-> Id; // This is either $ // name = $ element-> Data-> Name; // This either $ id = $ element [data] [ID] does not work; $ Name = $ element [data] [name]; $ Message = $ Id '-'. $ Name. ' & Lt; / Br & gt; '; }  

Why does not any idea return anything?

  $ Json = '{"data": [{"name": "zone" , "Id": "123"}, {"name": "dave", "id": "345"}], "other": {"foo": "bar"}} '; $ List = json_decode ($ json, true); Forex currency ($ list ['data'] as $ item) {echo $ item ['id'] "\ N"; Echo $ item ['name']. "\ N \ n"; }  

Here is a perfect example of working with that data.


Comments