【发布时间】:2011-07-05 16:31:56
【问题描述】:
我目前将一些数据作为数组从我的 CodeIgniter 控制器发送到视图:
//Send data to template
$this->load->view('generator/content', $data);
$data 在哪里:
$data = array_merge($page, $posts);
我希望在将$posts 中的一些数据发送到视图之前,通过调用我的库中的函数/方法来修改:
if (!empty($posts)) {
$posts = $this->my_library->modifyPosts($posts, $page_ID);
}
函数/方法中的内容包括str_replace、爆炸字符串、时间格式化以及通常将数组中的数据转换为可用格式。据我了解,最好使用库来做这些事情。
有没有一种方法可以重建数组并将其从库中返回到控制器,这样当我将数据传递给视图时,它就可以呈现了?
【问题讨论】:
标签: php arrays codeigniter controller