php - Illegal string offset, how to work with this data -


i've got array returned api call below. when try access data using key, illegal string offset. believe it's caused fact key names don't have ' around them, can't thing data coming external source.

any idea why happening or can ?

 [data] => array         (             [latest] => array                 (                     [value] => 123.59000                     [value_int] => 12359000                     [display] => $123.59000                     [display_short] => $123.59                     [currency] => usd                 ) 

im trying access data

     echo $element['value']; 

if looping $array, have value in $element variable.

you can expand array`s keys with:

foreach ($array $key => $value) {      echo $key . ' = ' . $value; } 

if want access value key, use without looping:

echo $array['value']; 

according edit - if have large array assigned $array variable, loop array value assigned data key with:

foreach ( $array['data'] $element ) {     echo $element['value']; } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -