我是 codeigniter 框架的新手。我正在使用 foreach 循环在数组内和数组内创建一个数组,以从 3 个表中获取记录。我已经像这样制作数组Array([devices] => Array ( [0] => Array ( [id] => 1 [device_name] => Smartphone [device_image] => device-images/1d57a675edbb2ff97c5bc35fce27517c.png [device_icon] => device-images/325af5a3587cdfc8f35ae345a2d432a3.png [all_manufacturers] => Array ( [0] => Array ( [id] => 1 [fk_device_id] => 1 [manufacture] => Apple [models] => Array ( [0] => Array ( [id] => 1 [fk_deviceid] => 1 [fk_manufactureid] => 1 [model_name] => iPhone 11 Pro Max ) [1] => Array ( [id] => 2 [fk_deviceid] => 1 [fk_manufactureid] => 1 [model_name] => iPhone 11 Pro )
1 回答
烙印99
TA贡献1829条经验 获得超13个赞
最后一个数组没有设置“all_manufacturers”,因此错误是您试图设置 $all_manufacturers 而不检查它是否已设置。
删除设备循环顶部的这一行:
$all_manufacturers = $device["all_manufacturers"];
然后更改这段代码:
<?php if ($all_manufacturers) { foreach ($all_manufacturers as $manufacture) { ?>
对此:
if (!empty($device["all_manufacturers"])) { foreach ($device["all_manufacturers"] as $manufacture) {
- 1 回答
- 0 关注
- 91 浏览
添加回答
举报
0/150
提交
取消