Controller:
$sid = $this->uri->segment(4);
$serial = $this->contract_items->get_all_serial($id);
$_items = array();
foreach ($serial as $k => $v) {
$oldserial = $this->contract_items->get_childrens($sid);
$_items[$v->contract_id] = array("children" => $oldserial);
}
$this->data['serial_items'] = $_items;
$this->build_view("contracts/serial.php");
これは、print_r() の出力であり、ビューに「FDO1643R26G」と「FDO1643R26G」を出力したい場合です。
Array ( [0] => Array ( [children] => Array ( [0] => stdClass Object ( [serial_num] => FDO1643R26G-XXX ) [1] => stdClass Object ( [serial_num] => FDO1643R26G-XXX-XXX ) ) ) )