非法字符串偏移,如何使用此数据[关闭]

I've got an array returned from an API call like below. When I try to access the data using its key, I get an illegal string offset. I believe it's caused by the fact that the key names don't have ' around them, but I can't do any thing about that as the data is coming from an external source.

Any idea why this is happening or what I can do about it ?

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

im trying to access the data like this

     echo $element['value'];

If you are looping your $array, you already have value in $element variable.

You can expand also array`s keys with:

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

If you want to access value with key, just use without looping:

echo $array['value'];

According to your edit - if you have large array assigned to the $array variable, loop array value assigned to data key with:

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