2016-11-25 63 views
0
Array 
(
[0] => Array 
    (
     [lead_id] => 1 
     [employee_id] => 2 
     [update_date] => 2016-11-25 
     [lead_status] => Fresh Leads 
     [reason] => Deal Won 
     [notes] => Array 
      (
       [0] => Array 
        (
         [notes] => Notes 1 
        ) 

       [1] => Array 
        (
         [notes] => Notes 2 
        ) 

       [2] => Array 
        (
         [notes] => Notes 3 
        ) 

      ) 

    ) 

[1] => Array 
    (
     [lead_id] => 1 
     [employee_id] => 5 
     [update_date] => 2016-11-25 
     [lead_status] => Fresh Leads 
     [reason] => Deal Won 
     [notes] => Array 
      (
       [0] => Array 
        (
         [notes] => Notes 1 
        ) 

       [1] => Array 
        (
         [notes] => Notes 2 
        ) 

       [2] => Array 
        (
         [notes] => Notes 3 
        ) 

      ) 

    ) 

[2] => Array 
    (
     [lead_id] => 3 
     [employee_id] => 2 
     [update_date] => 2016-11-25 
     [lead_status] => Fresh Leads 
     [reason] => Deal Won 
     [notes] => Array 
      (
       [0] => Array 
        (
         [notes] => Notes 1 
        ) 

       [1] => Array 
        (
         [notes] => Notes 2 
        ) 

       [2] => Array 
        (
         [notes] => Notes 3 
        ) 

      ) 

    ) 

) 

這是我的json數組。
我怎樣才能得到這個數組中的每個字段的值?
請幫助從json數組插入json_decode後在php

+4

這是不使用following url

這個讀JSON對象的簡單的代碼驗證您的JSON數組或JSON對象JSON。 – brian

+3

[在json \ _decode/multidimensional數組之後訪問JSON數組]可能的副本(http://stackoverflow.com/questions/14934660/accessing-json-array-after-json-decode-multidimensional-array) – rbr94

+2

這是php數組。 'foreach($ arr as $ ar){echo $ ar ['lead_id']; //爲其他人}} –

回答

0

這不是有效的JSON數組, 您可以使用PHP

$data = '{ 
    "name": "Saman", 
    "age": "19", 
     "records":[{ 
       "subject1":"Maths", 
       "marks":"67" 

      }] 
     }'; 

$character = json_decode($data); 
echo "Name :".$character->name; 
echo "Age :".$character->age;