1st of all yes im a new user, this forum looks really active and enjoyable, but the truth is i wouldn't have joined
if i didn't need any help, since im new in PHP and got some difficulties.
Problem:
I have a simple text file where there's some usual text with commas, spaces and dots lines separated by \n.
I have this function:
------------------------------------------------
Code: Select all
$sfile = 'test.txt';
function fcontent($sfile)
{
$fc = file_get_contents($sfile);
$del = "\n";
$arr = explode($del, $fc);
$fp = fopen("log.html", "w+");
foreach($arr as $key => $value)
{
fwrite($fp, $value . "\n");
}
}Point of this function would be then taking file content from text file, putting it in to array and writing it to html file.
Everything works, but as you might guess it's not final.
1. The file log.html appears totally w/o any html elements file wich is logical since i haven't added any html elements, this is the 1st task thing i would need help with to insert into html file <table><tr><td></td>Some text here</tr></table>.
2. The second aim for this function woul'd be to write to file as an array value.
e.g. <tr><td>. $arr[1] .</td></tr>
So if i had somewhat 5 values each in a different row,
function been executed for the 3rd time, it would look something like this.
Code: Select all
<tr>
<td>. $arr[11] .</td>
<td>. $arr[12] .</td>
<td>. $arr[13] .</td>
<td>. $arr[14] .</td>
<td>. $arr[15] .</td>
</tr>