Home >Backend Development >PHP Tutorial >The method of displaying array data through loop in view in codeigniter, codeigniterview_PHP tutorial
This article describes the example of the view in codeigniter displaying the array data through a loop. Share it with everyone for your reference. The details are as follows:
The controller is as follows:
<?php 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:
<html> <head> <title>display array data</title> </head> <body> <h1>Display array data</h1> <?php foreach($my_list as $item) { echo $item; } ?> </body> </html>
I hope this article will be helpful to everyone’s PHP programming based on codeigniter.