title: PHP: How to parse a stdClass Object?
body: <p>I'm trying to parse this data that is returned from <a href="https://smartystreets.com" rel="nofollow noreferrer">SmartyStreets</a> (it's an address verification company).</p>
  <p>Here is an example:</p>
  <pre><code>Array
  (
      [0] =&gt; stdClass Object
          (
              [input_index] =&gt; 0
              [candidate_index] =&gt; 0
              [delivery_line_1] =&gt; 3785 Las Vegas Blvd S
              [last_line] =&gt; Las Vegas NV 89109-4333
              [delivery_point_barcode] =&gt; 891094333992
              [components] =&gt; stdClass Object
                  (
                      [primary_number] =&gt; 3785
                      [street_name] =&gt; Las Vegas
                      [street_postdirection] =&gt; S
                      [street_suffix] =&gt; Blvd
                      [city_name] =&gt; Las Vegas
                      [state_abbreviation] =&gt; NV
                      [zipcode] =&gt; 89109
                      [plus4_code] =&gt; 4333
                      [delivery_point] =&gt; 99
                      [delivery_point_check_digit] =&gt; 2
                  )
  
              [metadata] =&gt; stdClass Object
                  (
                      [record_type] =&gt; H
                      [county_fips] =&gt; 32003
                      [county_name] =&gt; Clark
                      [carrier_route] =&gt; C024
                      [congressional_district] =&gt; 01
                      [building_default_indicator] =&gt; Y
                      [rdi] =&gt; Commercial
                      [latitude] =&gt; 36.10357
                      [longitude] =&gt; -115.17295
                      [precision] =&gt; Zip9
                  )
  
              [analysis] =&gt; stdClass Object
                  (
                      [dpv_match_code] =&gt; D
                      [dpv_footnotes] =&gt; AAN1
                      [dpv_cmra] =&gt; N
                      [dpv_vacant] =&gt; N
                      [active] =&gt; Y
                      [footnotes] =&gt; B#H#L#M#
                  )
  
          )
  
  )
  </code></pre>
  <p>I'm new to working in Objects, so I'm having difficulty understanding how this works. From the above print_r $result output, I'm trying to access [delivery_line1], [city_name], [state_abbreviation], [zipcode] and [plus4_code].</p>
  <p>How do I access this tree in PHP?</p>
  <p>I've tried this:</p>
  <pre><code>echo $result[&quot;delivery_line_1&quot;];
  </code></pre>
  <p>But that gives &quot;Undefined index: delivery_line_1&quot;.</p>
  <pre><code>echo $result-&gt;delivery_line_1;
  </code></pre>
  <p>But that gives &quot;Trying to get property of non-object&quot;.</p>
  <p>What am I missing? Thanks!</p>