3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $goods=["ABC","XYZ","PQR","DEF"]; $qty=[12345,25120,14521,12541]; $rate=[12.00,13.02,15.00,14.00]; $words=["Total Value", "Frieght", "Total Taxable Value", "Tax", "Tax", "Tax", "Total Tax Amount"]; ?> <table> <tr> <th>Sr No.</th> <th>Goods Description</th> <th>Total Quantity(pcs)</th> <th>Rate per unit(Rs.)</th> <th colspan="3">Amount</th> </tr> <?php for($i=0;$i<count($words);$i++) { ?> <tr> <td><?php echo $i+1 .".";?></td> <td><?php if(isset($goods[$i])) echo $goods[$i];?></td> <td><?php if(isset($qty[$i])) echo $qty[$i];?></td> <td><?php if(isset($rate[$i])) echo $rate[$i];?></td> <td><?php echo $words[$i];?></td> </tr> <?php } ?> </table>
based on di99N
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.2.0
<table> <tr> <th>Sr No.</th> <th>Goods Description</th> <th>Total Quantity(pcs)</th> <th>Rate per unit(Rs.)</th> <th colspan="3">Amount</th> </tr> <tr> <td>1.</td> <td>ABC</td> <td>12345</td> <td>12</td> <td>Total Value</td> </tr> <tr> <td>2.</td> <td>XYZ</td> <td>25120</td> <td>13.02</td> <td>Frieght</td> </tr> <tr> <td>3.</td> <td>PQR</td> <td>14521</td> <td>15</td> <td>Total Taxable Value</td> </tr> <tr> <td>4.</td> <td>DEF</td> <td>12541</td> <td>14</td> <td>Tax</td> </tr> <tr> <td>5.</td> <td></td> <td></td> <td></td> <td>Tax</td> </tr> <tr> <td>6.</td> <td></td> <td></td> <td></td> <td>Tax</td> </tr> <tr> <td>7.</td> <td></td> <td></td> <td></td> <td>Total Tax Amount</td> </tr> </table>