视图不显示控制器阵列的内容


view not displaying the contents of controller array

我有一个控制器,它从模型函数中提取数据并将数据存储在数组中:

    $row = $this->model_catalog_manufacturer->getAllManufacturers();
    $this->data['manufacturer']= array(
        'manufacturer_id'    => $row['manufacturer_id'],
        'name'   => $row['name'],
        'image'       => $row['image']
    );  

视图简单地接受数组并使用foreach循环迭代值并列出项。列表项出现了,但没有显示数组的文本值:

<ul>
<?php foreach ($manufacturer as $manuf) {?>
<li><?php echo $manuf['name'];?></li>
<?php }?>
</ul>

知道为什么吗?

代替

$row = $this->model_catalog_manufacturer->getAllManufacturers();
    $this->data['manufacturer']= array(
        'manufacturer_id'    => $row['manufacturer_id'],
        'name'   => $row['name'],
        'image'       => $row['image']
    );  

could you try

$rows = $this->model_catalog_manufacturer->getAllManufacturers();
foreach($rows as $row){
    $this->data['manufacturer'][]= array(
        'manufacturer_id'    => $row['manufacturer_id'],
        'name'   => $row['name'],
        'image'       => $row['image']
    );
}