Here is a simple example
Here is my controller named welcome.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function index()
{
$data['default'] = array(
array(
'email' => '[email protected]',
'username' => 'username1'
),
array(
'email' => '[email protected]',
'username' => 'username2'
),
array(
'email' => '[email protected]',
'username' => 'username3'
)
);
$data['title'] = 'Sample';
$this->load->view('welcome_message', $data);
}
}
In order to call the pass $data array in the views, we make sure that we have a reference key for the array like
$data['default'] = array
$data['title'] = 'Sample';
In order for me to access those data in my view
here is a sample view named
welcome_message.php
<html lang="en">
<head>
</head>
<body>
<div id="container">
<?php
foreach ($default as $key => $value) {
?>
<h1><?php echo $value['email'];?></h1>
<?php
}
?>
<h6><?php echo $title;?></h6>
</div>
</body>
</html>
To be able to access those data pass, I used the reference key of the pass array
default and title
and from there I can do the processing already
hope It could help you out.