title: Get specific values from CURL JSON response php array
body: <p>Trying to echo a couple of values from the CURL JSON response so i can put them in to a foreach loop but i can only get single indexed values to work.</p>
  
  <pre><code>$request = curl_init($api); // initiate curl object
  curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
  curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
  //curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment if you get no gateway response and are using HTTPS
  curl_setopt($request, CURLOPT_FOLLOWLOCATION, true);
  curl_setopt($request, CURLOPT_HTTPHEADER, array(
    "Content-Type: application/x-www-form-urlencoded"
  ));
  
  $response = (string)curl_exec($request); // execute curl fetch and store results in $response
  
  curl_close($request); // close curl object
  
  $result = json_decode($response, true); // true turns it into an array
  echo 'First Name: ' . $result['first_name'] . '&lt;br /&gt;'; // why doesnt this work
  echo 'Last Name: ' . $result[0]['last_name'] . '&lt;br /&gt;'; // yet i can return the first value
  </code></pre>
  
  <p>Example Array output</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [id] =&gt; 34761
              [first_name] =&gt; A
              [last_name] =&gt; Bailes
              [clinic] =&gt; 
              [phone] =&gt; 7409923279
              [fax] =&gt; 7409926740
              [address1] =&gt; 507 Mulberry Heights Rd
              [address2] =&gt; 
              [city] =&gt; Pomeroy
              [subdivision] =&gt; OH
              [country_code] =&gt; 
              [postal_code] =&gt; 45769-9573
              [timezone] =&gt; Array
                  (
                      [timezone_type] =&gt; 3
                      [timezone] =&gt; America/New_York
                  )
  
              [state] =&gt; OH
          )
  )
  </code></pre>
  
  <p>I have json decode set to true for array output</p>
  
  <pre><code>$result = json_decode($response, true); // true turns it into an array
  </code></pre>
  
  <p>but when i try to echo the 'first_name' values it just returns empty.</p>
  
  <pre><code>echo 'First Name: ' . $result['first_name'] . '&lt;br /&gt;'; // why doesnt this work
  </code></pre>
  
  <p>Yet i can return an indexed value</p>
  
  <pre><code>echo 'First Name: ' . $result[0]['first_name'] . '&lt;br /&gt;';
  </code></pre>
  
  <p>What am i doing wrong here?</p>