2013-10-09 85 views
1

嗨,如果要執行此操作,請稍等。因爲到目前爲止我現在所做的是失敗。 這是json轉向數組的示例輸出。從多級別數組中檢索值

 Array 
    (
     [0] => Array 
      (
       [0] => Array 
        (
         [value] => lit-PR-00-Preparing-Precise-Polymer-Solutions.html 
        ) 

      ) 

     [1] => Array 
      (
       [0] => Array 
        (
         [value] => 90Plus 
        ) 

      ) 

     [2] => Array 
      (
       [0] => Array 
        (
         [value] => Particle Size Analyzer 
        ) 

      ) 

    ) 

到目前爲止,這是我得到到目前爲止,它仍然無法輸出我需要的價值。希望得到一些幫助,我在做什麼錯誤的感謝。

$decode = json_decode($row['elements'], true); 

       echo '<pre>'; 
       //print_r($decode); 
       print_r(array_values($decode)); 
       echo '</pre>'; 

       echo ($value['0'][1][value]); 

回答

1
$decode = json_decode($row['elements'], true); 

// iterate through array 
foreach($decode as $array_row) { 
    echo $array_row[0]['value']; 
} 

// display specific row #2 
echo $decode[2][0]['value'];