从 json 格式获取数据错误


Fetching data error from json format

我有以下 JSON 格式

 Array (
    [version] => 3 
    [status] => ok 
    [response] => Array (
        [data] => Array (
            [0] => Array (
                [accessible_wheelchair] => 1
                [address] => 200 5th Ave
                [category_labels] => Array (
                    [0] => Array (
                        [0] => Social
                        [1] => Food and Dining
                        [2] => Restaurants
                        [3] => Italian
                    )
                    [1] => Array (
                        [0] => Social
                        [1] => Food and Dining
                        [2] => Restaurants
                        [3] => Steakhouses
                    )
                    [2] => Array (
                        [0] => Social
                        [1] => Entertainment
                        [2] => Music and Show Venues
                    )
               )
               [country] => us
           )
        )
        [included_rows] => 20
    )
) 

我想从 data->[0] 数组中获取数据。我使用以下代码将数据插入数据库

$newurl="/*the api link is here*/";
$json = file_get_contents($newurl); 
$data = json_decode($json,true);
foreach($data as $value){
        $value1=$value;//$value
        foreach($value as $newValue){
                foreach($newValue as $newValue1){
                    $name=$newValue1["name"];
                    $sql="insert into restaurant (name) values(".$name.");";
                    db_query($sql) or die("insert error");
                }
        }
    }

但它无法插入数据。请问是否有任何其他方法可以获取我想要的数据并将其存储在数据库中。

餐厅名称在哪里?

<?php
$newurl="/*the api link is here*/";
$json = file_get_contents($newurl);
if ($json)         
{             
    if (!($response = json_decode(stripslashes($json), TRUE)))             
    {                 
        die("invalid json format");      
    }         
}
if (!empty($response['status']) && $response['status'] == "ok")
{   
    $data = $response['response']['data'];
    for ($i=0; $i < count($data); $i++) 
    { 
        // in this step data 0 wich you want to extract
        /*
        [accessible_wheelchair] => 1
                [address] => 200 5th Ave
                [category_labels] => Array (
                    [0] => Array (
                        [0] => Social
                        [1] => Food and Dining
                        [2] => Restaurants
                        [3] => Italian
                    )
                    [1] => Array (
                        [0] => Social
                        [1] => Food and Dining
                        [2] => Restaurants
                        [3] => Steakhouses
                    )
                    [2] => Array (
                        [0] => Social
                        [1] => Entertainment
                        [2] => Music and Show Venues
                    )
               )
        */
    // but what i confused here is restaurant name? i don't see restaurant name here..
    }
}