-1
我有它輸出數組:PHP的foreach數組問題
stdClass Object ([firstName] => Rupert [headline] => Managing Director at
READ Advisors [lastName] => Bowen-Jones [pictureUrl] =>
https://media.licdn.com/mpr/mprx/0_yrLwHnXDTWGSypSo-
B_NHz9hiu52pMpoOAAqHzLxpolpijIEr9zbQvllDTL1xYj6g1FvFtBsywhL)
而且我想挑選出每個項目:
foreach ($user_data as $key => $value) {
echo "<br />" . $value['firstName'] . "<br />";
}
但我發現了以下錯誤:
stdClass Object ([firstName] => Rupert [headline] => Managing Director at
READ Advisors [lastName] => Bowen-Jones [pictureUrl] =>
https://media.licdn.com/mpr/mprx/0_yrLwHnXDTWGSypSo-
B_NHz9hiu52pMpoOAAqHzLxpolpijIEr9zbQvllDTL1xYj6g1FvFtBsywhL)
Warning: Illegal string offset 'firstName' in
/home/readadvisors/readadvisors.com/auth/linkedin/callback.php on line 26
R
Warning: Illegal string offset 'firstName' in
/home/readadvisors/readadvisors.com/auth/linkedin/callback.php on line 26
M
Warning: Illegal string offset 'firstName' in
/home/readadvisors/readadvisors.com/auth/linkedin/callback.php on line 26
B
Warning: Illegal string offset 'firstName' in
/home/readadvisors/readadvisors.com/auth/linkedin/callback.php on line 26
h
您的幫助將非常感謝! 魯珀特
它不是一個數組是一個對象,所以你需要使用像obj- $>的firstName –
使用'$ user_data-> firstName' –