PHP JSON decode from Airtable fetch

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
$json = '{
  "records":[
    {
        "id":"recuUH8PF7iSJqbAW",
        "fields":{
                "Name":"Alexander Calder"
        },
        "createdTime":"2015-02-09T23:04:03.000Z"
    },
    {
        "id":"reciFiTCo7IabVLC3",
        "fields":{
            "Name":"Edvard Munch"
        },
        "createdTime":"2015-02-10T00:15:45.000Z"
    },
    {
        "id":"recffnVZK320B8XMk",
        "fields":{
            "Name":"Frida Kahlo"
        },
        "createdTime":"2015-02-09T23:54:23.000Z"
    },
    {
        "id":"recRQgpEViiDC5Jsh",
        "fields":{
            "Name":"Paul Klee"
        },
        "createdTime":"2015-02-09T23:41:00.000Z"
    }
  ]
}';

$json_ob = json_decode($json);
$rows = $json_ob->records;
foreach ($rows as $row){
    echo $row->fields->Name."\n";
}
  • Alexander Calder
  • Edvard Munch
  • Frida Kahlo
  • Paul Klee