CI列表渲染
Wscats opened this issue · 0 comments
Wscats commented
关键是用foreach方法来渲染
视图 View:
<!DOCTYPE html>
<html>
<head>
<title>hello</title>
</head>
<body>
<ul>
<?php foreach ($wsscat_list as $item):?>
<li>
<?php
if(is_array($item)){
echo "我的第一个技能是".$item['first']."我的第二个技能是".$item['second'];
}
else{
echo "我的名字是".$item;
};?>
</li>
<?php endforeach;?>
</ul>
</body>
</html>
控制器 Controllers
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Hello extends CI_Controller
{
public function index()
{
$data['wsscat_list'] = array(
'name' => 'Wsscat',
'Autumns',
array('first' => 'JS', 'second' => 'PHP'),
);
$this->load->view('hello', $data);
}
}