我使用 ZF1,如果出现以下情况,我需要输入标题:
title="<?php echo isset($this->region['klu']) ? $this->region['klu'] : 'region name for klu'?>"
其中 klu - 是我表中 r_alias 行中的数据
所以,在我的 Controller 中我做了这样的事情:
$region = Map_Model_Map_Factory::getFetchAll();
$this->view->assign('region', $region);
什么是 getFetchAll():
static function getFetchAll()
{
$table = new Map_Model_Map_Table();
$select = $table->select()
->order('r_alias ASC');
return $table->fetchAll($select);
}
但是这里出了点问题,我需要有 echo 区域,而不是空页面。
最佳答案
你试过这样吗
$data['region'] = Map_Model_Map_Factory::getFetchAll();
//echo '<pre>';
//print_r($data['region']); // only for testing
$this->view->assign('region', $data);
在 View 中回显
echo $region['klu'];
关于php - 以正确的方式输出数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15921016/