php - Access array elements from API -


for life of me can not figure out how access values of array. every example stdclass object has type of value. if try example $obj->0->0->city; error.

can show me example how access [city] => toronto or [date_created] => 2011-05-03 14:33:58?

i tried no luck.

$object = $buy[1];  $title = $object->title[0]; echo "$title"; 

thanks

this api gives me.

stdclass object (     [id] => 1     [name] => toronto     [date_modified] => 2011-03-08 13:07:10     [tax_rate_provincial] =>  ) <br/>  array (     [0] => stdclass object         (             [0] => stdclass object                 (                     [id] => 28131844                     [full_date] => 20110506                     [end_date] => 20110511                     [city] => toronto                     [saved] => 1651                     [discount_percentage] => 52                     [deal_option] => array                         (                             [0] => stdclass object                                 (                                     [id] => 2600                                     [title] =>                                      [date_modified] => 0000-00-00 00:00:00                                     [date_created] => 2011-05-03 14:33:58                                     [value] => 3150                                     [price] => 1499                                     [deal_id] => 28131844                                     [is_default] => 0                                 )                          )                      [options] =>                      [option_quantity] =>                      [option_remaining] =>                      [purchase_limit] => 1                     [gift_limit] => 0 

there special evil syntax bypass numeric object attributes:

 print $obj->{'0'}->{'0'}->city; 

is correct syntax, , equivalent path determined.

your second example array however, it's probably:

 print $array[0]->{'0'}->city; 

the alternative foreach on specific level - works objects , arrays likewise.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -