我有這個陣列PHP數組的數組警告:非法串偏移
//this is onw part of `$pins['location']`
array(9) {
["address"]=> string(23) "11xxx Hudderfield xxxxxx"
["city"]=> string(12) "Jxxxxxx"
["houseNumber"]=> string(5) "11xxx"
["id"]=> NULL
["state"]=> string(2) "xx"
["country"]=> NULL
["street"]=> string(17) "Hudderfield xxxxx"
["unit"]=> NULL
["zip"]=> string(5) "xxxx"
}
的錯誤:
它的代碼時跑了我的錯誤警告一個更大的數組中:非法串偏移「地址」中/home/../../../cron.php上線77
76 foreach ($pins['location'] as $pin_lo) {
77 $location_address = $pin_lo['address'];
78 echo $location_address;
79 $location_city = $pin_lo['city'];
80 echo $location_city;
81 }
我需要能夠數組值傳遞給一個變量,你可以看到。如果我dd($ pins ['location']);它顯示了一切,因爲字符串不確定當數組在foreach後得到改變時它只會返回每一行的第一個字母或數字的任何想法?
退房此[鏈接] https://stackoverflow.com/questions/9869150/illegal-string-offset-warning-php – lovelace