How to display array data through loop in view in codeigniter_PHP tutorial

WBOY
Release: 2016-07-13 10:01:17
Original
885 people have browsed it

The method of view in codeigniter to display array data through loop

This article mainly introduces the method of view in codeigniter to display array data through loop. An example analysis of the view method in codeigniter and The skills of array traversal have certain reference value. Friends in need can refer to it

The example in this article describes how the view in codeigniter displays array data through a loop. Share it with everyone for your reference. The details are as follows:

The controller is as follows:

?

1

2

3

4

5

6

7

8

9

10

class SimpleController extends Controller

{

function index()

{

$data['my_list'] = array("do this", "clean up", "do that");

$this->load->view('index', $data);

}

}

?>

1 2

3

4

5

6

1

2

3

4

5

6

7

8

9

10

11

12

13

14

display array data

Display array data

foreach($my_list as $item)

{

echo $item;

}

?>

7 8

9 10

class SimpleController extends Controller { function index() { $data['my_list'] = array("do this", "clean up", "do that"); $this->load->view('index', $data);
}
}
?>
Index view is as follows: ?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 display array data

Display array data

<🎜>foreach($my_list as $item)<🎜> <🎜>{<🎜> <🎜>echo $item;<🎜> <🎜>}<🎜> <🎜>?>
I hope this article will be helpful to everyone’s PHP programming based on codeigniter. http://www.bkjia.com/PHPjc/971956.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/971956.htmlTechArticleHow to display array data through a loop in view in codeigniter. This article mainly introduces how to display array data through loop in view in codeigniter. Method, example analysis of the view method in codeigniter...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template