Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI列表渲染 #1

Open
Wscats opened this issue Nov 17, 2016 · 0 comments
Open

CI列表渲染 #1

Wscats opened this issue Nov 17, 2016 · 0 comments

Comments

@Wscats
Copy link
Owner

Wscats commented Nov 17, 2016

关键是用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);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant