Extract Data From Text File
Posted: Fri Jul 15, 2022 10:15 pm
This may not be the forum to use for this request and if it goes against any policies, just delete it.
I have set up a subscribe form on my blog which takes an email address and enters it into a text file on the server. The data is in this format:
me@myemail.com,you@youremail.com,we@youremail.com, etc
I want the data to be displayed in this format using php and it would be dynamic in that as email addresses are added, the column would display the new email addresses:
me@myemail.com
you@youremail.com
we@youremail.com
I have tried to use the explode() function but have not been able to get it to work. Right now, the code shown below pulls the data from the text file in the same format...that is in one continuous line. Can anyone of the gurus on this form help me with this?
Thanks
I have set up a subscribe form on my blog which takes an email address and enters it into a text file on the server. The data is in this format:
me@myemail.com,you@youremail.com,we@youremail.com, etc
I want the data to be displayed in this format using php and it would be dynamic in that as email addresses are added, the column would display the new email addresses:
me@myemail.com
you@youremail.com
we@youremail.com
I have tried to use the explode() function but have not been able to get it to work. Right now, the code shown below pulls the data from the text file in the same format...that is in one continuous line. Can anyone of the gurus on this form help me with this?
Code: Select all
<body><center>
<table>
<tr>
<th>Current Subscribers</th>
</tr>
<?php
if(!file_exists("data.txt"))
{
echo "The file cannot be found!";
exit;
}
$fp = fopen("data.txt", "r");
if(!$fp)
{
echo "File cannot be opened";
exit;
}
echo "<table border = 2>";
while(!feof($fp))
{
$info = fgets($fp);
echo "<tr>";
echo "<td>$info</td>\n";
echo "<br />";
}
echo "</tr>\n";
echo "</table>";
fclose($fp)
?>
</body>