我希望将每个值存储在数组中,以便在数组本身被迭代时加载视图。我一直在使用for将其作为以下代码实现:
$seat = (0 => 'a', 1 => 'b', 2 => 'c', 3=> 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k');
$number = 10;
for ($i=0; $i <= $number; $i++) {
$this->data['chunked'] = $seat[$i];
$this->load->view('chunked', $this->data);
}如何使用foreach应用相同的内容,在迭代数组$seat本身时发送数组的当前值?
foreach ($seat as $key => $value) {
$this->data['chunked'] = //how to set the current array value being iterated
$this->load->view('chunked', $this->data);
}关键是,我想使用<div>根据$seat中的数组键生成一些列。所以在这个例子中,我有11个键从0开始到10,我希望在迭代数组的同时生成列。最后,我将有11个<div>列
发布于 2016-03-07 11:28:26
foreach ($seat as $key => $value) {
$this->data['chunked'] = $seat[$key]; //how to set the current array value being iterated
$this->load->view('chunked', $this->data);
}要实现完全相同的目的,可以执行以下添加操作
$seat[$key];https://stackoverflow.com/questions/35841738
复制相似问题