PHP Code:
<!DOCTYPE html>
<html>
<head>
<style>
td{
padding: 5px;
font-size: 20px;
}
</style>
</head>
<body>
<h3>Php Code to read data from txt file and display it in html table</h2>
<?php
$myfile = fopen("program4.txt", "r") or die("Unable to open file!");
$data = fread($myfile,filesize("program4.txt"));
$result = explode(',', $data);
?>
<table border="1">
<tr>
<td><?php echo $result[0]; ?></td>
</tr>
<tr>
<td><?php echo $result[1]; ?></td>
</tr>
<tr>
<td><?php echo $result[2]; fclose($myfile); ?></td>
</tr>
</table>
</body>
</html>
Output:
Comments
Post a Comment