2014-12-05 57 views
0

這是json_decode的結果& echo我收到了,但我無法構建它的列表/表格。到目前爲止,我在這個主題上找到的所有東西都不適合我,也許是因爲複雜的嵌套。我會感謝任何幫助,只要指向正確的方向,不需要爲我做所有的工作。提前致謝!無法從json_decode的結果中提取數據php

Array 
(
    [1001] => Array 
     (
      [Element] => Array 
       (
        [id] => 1001 
        [name] => Element 1 
       ) 

     ) 

    [1002] => Array 
     (
      [Element] => Array 
       (
        [id] => 1002 
        [name] => Element 2 
       ) 

     ) 

    [1003] => Array 
     (
      [Element] => Array 
       (
        [id] => 1003 
        [name] => Element 3 
       ) 

     ) 
) 
+0

使用'foreach'通過一個GET JSON數據之一。這裏必須使用嵌套的'foreach'循環獲取結果數據並保存。 – himansu 2014-12-05 09:41:52

回答

1

嘗試的foreach

foreach ($your_json_array as $key=>$value){ 
     foreach($value as $ele=>$elearray){ 
      echo $elearray['id']; 
      echo $elearray['name']; 
     } 
    }