ArrayData.php
<?php
class ArrayData extends CI_Controller {
public function index()
{
$data['title'] = "CI Test : Table Array";
$data['heading'] = "Data Mahasiswa Terbaik Tahun 2016<br><hr width=50% size=10 color=#a3a3f3>";
$data['npm'] = array('2141630049','2141630048', '2141630050', '2141630077');
$data['nama'] = array('Deni Muhardian','Azam', 'omet', 'Firly');
$data['usia'] = array('22','24', '24', '28');
$data['ttl'] = array('Bogor, 29 Oktober','Depok, 08 Oktober', 'NTB, 1 Januari', 'Papua, 30 February');
$data['ipk'] = array('4.00,'3.22', '3.50', '3.01');
$this->load->view('ArrayView', $data);
}
}
=====================================================
ArrayView.php
<html>
<head>
<title><?php echo $title;?></title>
</head>
<body>
<center><h3><?php echo $heading;?></h3>
<table border=1 bordercolor="#CC0000" style="border-style:hidden">
<tr>
<th>No</th>
<th>NPM</th>
<th>Nama</th>
<th>Usia</th>
<th>Tempat, Tanggal Lahir</th>
<th>IPK</th>
</tr>
<?php
for ($i=0; $i<=3; $i++)
{
$no++;
echo "
<tr>
<td align='center'>$no</td>
<td>$npm[$i]</td>
<td>$nama[$i]</td>
<td align='right'>$usia[$i]</td>
<td>$ttl[$i]</td>
<td>$ipk[$i]</td>
</tr>";
}
?>
</table>
</center>
</body>
</html>