I have an array in the below format. This array had around 100 elements in same format. I want to represent the whole array in a specific format of table using DOMPDF
library using codeIgniter.
result = Array(
[0] => Array (
['brand'] => x,
['product'] =>p1,
['language']=>English,
);
[1] => Array (
['brand'] => x,
['product'] =>p2,
['language']=>English,
);
);
I like to represent them in the below format using <table>
tags in html
.
Brand x y
Product p1 p2
Language English English
I am looking for ideas. I have those kind of array elements not 2 more than 100. I want to loop them.
So after request below i am going to post my code.
<?php foreach($result as $res)
{
<table>
<tr>
<td>Brand</td>
<td><?php echo $res['brand'] ?></td>
</tr>
<tr>
<td>Product</td>
<td><?php echo $res['product'] ?></td>
</tr>
<tr>
<td>Language/td>
<td><?php echo $res['language'] ?></td>
</tr>
</table>
}
This will give you output for one product like this.
Brand x
Product p1
Language English
How I can do loop for other products to get output of how I want above?
Note: not only 3 fields in each array element. I have more than 30 fields. May be you think I am going this way only because of print able area in the PDF page.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With