php错误:未访问的typeerror:无法访问字符串上字符串的偏移
我知道有许多类似的“ TypeError:无法访问字符串上的字符串偏移”,但每个人都不同,我阅读了它们。如何跳过嵌套值?我们只需要地址_line_1,城市等。
这是代码:
foreach ($jd as $line) {
if(!in_array($line['phone'], array_column($csv, 'phone'))){
$newarray[sizeof($newarray)]=$line; //add unique row
fputcsv($file, $line); //update the master csv file
}
}
这就是某些数据的样子
[address_line_1] => 10860 Larry Dr, Northglenn, CO 80233
[address_line_2] =>
[anonymous] =>
[blocked] =>
[campaign_id] => o1RqNONn9jHnnBRd1M9A
[campaign_name] => K1Keto Camp 4/28
[city] => Northglenn
[company] =>
[country] => US
[created_date_unix] => 1656104474
[customer_card] => Array
(
)
[customer_group] => Array
(
[0] => Array
(
[id] => P67902g06ZfaN1O64p08
[name] => Prospect
)
)
[email] => [email protected]
[enabled] => 1
[first_name] => William
[full_address] => 10860 Larry Dr, Northglenn, CO 80233, USA
[geocode_success] => 1
[google_place_id] => ChIJy8IV-5p2bIcRE9IovuASaOY
[id] => y2JWmaLGP1TdP0qoMzM5
[internal_id] =>
[last_name] => Wolters
[lat] => 39.8933644
[lifetime_value] => Array
I understand there are many similar "TypeError: Cannot access offset of type string on string" but everyone is different, and i read them. How do I skip over the nested values? We only need address_line_1, City etc.
this is the code:
foreach ($jd as $line) {
if(!in_array($line['phone'], array_column($csv, 'phone'))){
$newarray[sizeof($newarray)]=$line; //add unique row
fputcsv($file, $line); //update the master csv file
}
}
This is what some of the data looks like
[address_line_1] => 10860 Larry Dr, Northglenn, CO 80233
[address_line_2] =>
[anonymous] =>
[blocked] =>
[campaign_id] => o1RqNONn9jHnnBRd1M9A
[campaign_name] => K1Keto Camp 4/28
[city] => Northglenn
[company] =>
[country] => US
[created_date_unix] => 1656104474
[customer_card] => Array
(
)
[customer_group] => Array
(
[0] => Array
(
[id] => P67902g06ZfaN1O64p08
[name] => Prospect
)
)
[email] => [email protected]
[enabled] => 1
[first_name] => William
[full_address] => 10860 Larry Dr, Northglenn, CO 80233, USA
[geocode_success] => 1
[google_place_id] => ChIJy8IV-5p2bIcRE9IovuASaOY
[id] => y2JWmaLGP1TdP0qoMzM5
[internal_id] =>
[last_name] => Wolters
[lat] => 39.8933644
[lifetime_value] => Array
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在尝试索引之前,请检查
$ line
是一个数组。Check if
$line
is an array before trying to index it.您可以尝试两件事:
is_array($ line)来查看$ line是否真的是一个数组
,并查看使用isset()的节点是否真的存在;
You can try 2 things:
is_array($line) to see if $line is really an Array
and see if the nodes really exist using the isset();