Array representation in a specific way of table format in codeIgniter view file? Array representation in a specific way of table format in codeIgniter view file? codeigniter codeigniter

Array representation in a specific way of table format in codeIgniter view file?


Use foreach for getting each array from result array. and use multiple array (row[ ][ ]) with key. you can print <tr><td> all are in echo.


@Vengat, following coding are working Good. Try This One...

<?php$result = Array(              0 => Array (                     'brand' => 'x',                     'product' =>'p1',                     'language'=>'English',                    ),              1 => Array (                     'brand'=> 'y',                     'product' =>'p2',                     'language'=>'English',                    )              );    echo '<table>';    echo '<tr><td>Brand</td>';    foreach($result as $res)    {        echo "<td>".$res['brand']."</td>";    }    echo '</tr>';    echo '<tr><td>Product</td>';    foreach($result as $res)    {        echo "<td>".$res['product']."</td>";    }    echo '</tr>';    echo '<tr><td>Language</td>';    foreach($result as $res)    {        echo "<td>".$res['language']."</td>";    }    echo '</tr>';       echo '</table>';?> 

Output is:

Brand   x   yProduct p1  p2Language    English English

Use css for alignment.