Codeigniter爆炸文件名并返回视图只提供一个文件

I have multiple files that have this name format field1_field2_field3.pdf. I separated each field and I want to return it to the view and paginate it. Can it be done? So far I have managed to explode the filename but only one file is returned to the view. Please help.

Controller :

    $this->load->helper('directory');
    $map = directory_map('./assets/data/');
    $nric = $this->session->userdata('nric');
    foreach($map as $row)
    {
        $separate = explode('_',$row);
    }
    $data['name'] = $separate[0];
    $data['product'] = $separate[1];
    $data['policyno'] = substr($separate[2],0,strlen($separate[2])-4);
    $this->load->view('includes/user/header');
    $this->load->view('user/statements',$data);
    $this->load->view('includes/user/footer');

View

<tr>
<td><?php echo $name; ?></td>
<td><?php echo $product; ?></td>
<td><?php echo $policyno; ?></td>
</tr>

In your Controller you want the data array to contain multiple value so do something like this

EDIT: I am assuming that your $map variable is something like this (do a print_r if you want to see)

$map = [
    'field1_field2_field3.pdf',
    'field11_field22_field33.pdf',
    'field111_field222_field333.pdf'
]

So using the loop

foreach($map as $row)
{
    $separate = explode('_',$row);
    $data[] = [ 
        'name' => $separate[0],
        'product' => $separate[1],
        'policyno' => substr($separate[2],0,strlen($separate[2])-4)
    ];
}

Now doing as mentioned above in the foreach loop will give you $data like

$data = [
    0 => [
        'name' => 'field1',
        'product' => 'field2',
        'policyno' => 'field3',
    ],
    1 =>  [
        'name' => 'field11',
        'product' => 'field22',
        'policyno' => 'field33',
    ],
    2 =>  [
        'name' => 'field111',
        'product' => 'field222',
        'policyno' => 'field333',
    ],
]

this $data you can pass to your view, as you were doing

$this->load->view('user/statements',$data);

then in your view you can have something like

<table>
    <?php foreach ($data as $dataRow):?>
        <tr>
            <td><?php echo $dataRow['name']?></td>
            <td><?php echo $dataRow['product']?></td>
            <td><?php echo $dataRow['policyno']?></td>
        </tr>
    <?php endforeach?> 
</table>

I think this should work :)

Now use some fancy JavaScript plug-in and create a paginated view