PHP: How to parse a stdClass Object? -


i'm trying parse data returned smartystreets (it's address verification company).

here example:

array (     [0] => stdclass object         (             [input_index] => 0             [candidate_index] => 0             [delivery_line_1] => 3785 las vegas blvd s             [last_line] => las vegas nv 89109-4333             [delivery_point_barcode] => 891094333992             [components] => stdclass object                 (                     [primary_number] => 3785                     [street_name] => las vegas                     [street_postdirection] => s                     [street_suffix] => blvd                     [city_name] => las vegas                     [state_abbreviation] => nv                     [zipcode] => 89109                     [plus4_code] => 4333                     [delivery_point] => 99                     [delivery_point_check_digit] => 2                 )              [metadata] => stdclass object                 (                     [record_type] => h                     [county_fips] => 32003                     [county_name] => clark                     [carrier_route] => c024                     [congressional_district] => 01                     [building_default_indicator] => y                     [rdi] => commercial                     [latitude] => 36.10357                     [longitude] => -115.17295                     [precision] => zip9                 )              [analysis] => stdclass object                 (                     [dpv_match_code] => d                     [dpv_footnotes] => aan1                     [dpv_cmra] => n                     [dpv_vacant] => n                     [active] => y                     [footnotes] => b#h#l#m#                 )          )  ) 

i'm new working in objects i'm have difficulty understanding how works. above print_r $result output, i'm trying access [delivery_line1], [city_name], [state_abbreviation], [zipcode] , [plus4_code].

how access tree in php?

i've tried this:

echo $result["delivery_line_1"]; 

but gives "undefined index: delivery_line_1".

echo $result->delivery_line_1; 

but gives "trying property of non-object".

what missing? thanks!

$result[0]->delivery_line_1; 

$result array containing object.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -