JSON foreach only gets first result out of an array
<p>I have a JSON file (test.json) which is</p>

<pre><code>{
    "fruit": [{
        "id": 364823,
        "name": "Lemon",
        "amount": [33],
        "profile": "http://google.com",
        "buyid": 5
    }, {
        "id": 367851,
        "name": "Orange",
        "amount": [69, 95, 166],
        "profile": "http://google.com",
        "buyid": 3
    },{
        "id": 35647,
        "name": "Apple",
        "amount": [77, 43],
        "profile": "http://google.com",
        "buyid": 31
    } ]
}
</code></pre>

<p>then i have my PHP script to echo</p>

<pre><code>$url="test.json";
    $json = file_get_contents($url);
    $json = json_decode($json, true);
    $names = array();
    foreach($json['fruit'][0]['amount'] as $val) 
{
    echo $val . " &lt;br&gt; ";
}
</code></pre>

<p>Which returns </p>

<pre><code>33
</code></pre>

<p>how can i get it to return?</p>

<pre><code>33
69 95 166
77 43
</code></pre>

<p>i can get it to work with the others like <em>id</em>,<em>profile</em> and <em>buyid</em> but not this array</p>