我有一个功能如下:
function get_employee_information()
{
$this->db
->select('id, name');
$query = $this->db->get('sales_people');
$employee_names = array();
$employee_ids = array();
foreach ($query->result() as $row) {
$employee_names[$row->id] = $row->name;
$employee_ids[] = $row->id;
}
}
我正在尝试从输出到模板中访问这些数据,如下所示:
$this->get_employee_information();
$output = $this->template->write_view('main', 'records', array(
'employee_names' => $employee_names,
'employee_ids' => $employee_ids,
), false);
然而,这并没有显示任何东西。我觉得这是一件小事,我应该知道得更好。当我在函数内的任一数组上调整 print_r($arrayname) 时,我得到了可疑的数组值。当我 print_r OUTSIDE 函数时,它什么也不返回。