i have a problem with my 2nd array to display it in the table.. can anyone help me out..
<?php
$logdate = "20140918";
$fileloc = $logdate."TPL.log";
if (file_exists($fileloc)) {
$result = array();
$file = explode("\n", file_get_contents($fileloc));
$rowFile = count($file);
?>
<table cellpadding="5" cellspacing="0" width="100%" border="1">
<thead>
<tr>
<th>#</th>
<th>Transaction ID</th>
<th>X</th>
</tr>
</thead>
<tbody>
<?php
$x=1;
foreach ( $file as $content ) {
$result[] = array_filter(array_map("trim", explode(";", $content)));
?>
<tr>
<td><?=$x?></td>
<td><?=$result[$x][0]?></td>
<td><?=$result[$x][9]?></td>
</tr>
<?php
$x++;
}
?>
</tbody>
</table>
<?php
} else {
echo "File x exists";
}
?>
actually i want to insert the record into database.. but i want it to view in the table first. how i want to view the explode result in column..
Your code has major problems. For once, you never close the first
if. Or, indexes in the array start with0, not1, so you do not need$x. And I also do not understand what<?=$x?>has to be or what you mean with this. Try this:If you spend more time maintaining your own code, that would probably be a good thing.