title: How to access a specific field of a json array in php?
body: <p>I'm working with an API that returns arrays in json format. The code in json that is received is: </p>
  
  <pre><code>Array ([0] =&gt; Array ([phone] =&gt; 000123123 [_id] =&gt; 52e68920acfced017af80234 [name] =&gt; John [email] =&gt; john@gmail.com [country] =&gt; France) [1] =&gt; Array ([phone] =&gt; 111222333 [_id] =&gt; 52e68acas87fa0987a [name] =&gt; James [email] =&gt; james@gmail.com [country] =&gt; Germany))  
  </code></pre>
  
  <p>I want to access each field of the json array in my php file to process data individually. For example, to access the name of first register, I use the following code: </p>
  
  <pre><code>$cuerpoRespuesta = ejecutarPOST($URLS['retrieve'], $api_id, $api_key, array()); // This is the API call and I keep the json array in "$cuerpoRespuesta". 
  
  $data = json_decode($cuerpoRespuesta, TRUE); //Now I decode json array
  echo $data[0]["name"];                       //Here I show data
  </code></pre>
  
  <p>But doesn't shows anything, I get the following error: </p>
  
  <blockquote>
    <p>Warning: json_decode() expects parameter 1 to be string, array Given in C:\Retrieve.php on line 65</p>
  </blockquote>
  
  <p>Line 65 corresponds to json_decode. What am I doing wrong? Thanks for the help in advance.</p>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>I've tried the var_dump($cuerpoRespuesta) function and I get this:</p>
  
  <pre><code>array (size=2)
    0 =&gt; 
      array (size=5)
        'phone' =&gt; string '000123123' (length=9)
        '_id' =&gt; string '52e68920acfced017af80234' (length=24)
        'name' =&gt; string 'John' (length=4)
        'email' =&gt; string 'john@gmail.com' (length=14)
        'country' =&gt; string 'France' (length=6)
    1 =&gt; 
      array (size=5)
        'phone' =&gt; string '000123123' (length=9)
        '_id' =&gt; string '52e68ac7acfced017af80235' (length=24)
        'name' =&gt; string 'John' (length=4)
        'email' =&gt; string 'john@gmail.com' (length=14)
        'country' =&gt; string 'France' (length=6)
  </code></pre>
  
  <p>According to the API documentation is Json, but... if it's not, I don't know what it is :/</p>