Hello there, I have an array ($studs) and i would like to write its contents in a txt file. However, it only writes the last element of the array. Does anybody know how to resolve that?
<p> ALLOCATION TABLE </p>
<table>
<tr><td class = "header"> STUDENT </td>
<td class = "header"> TOPIC </td></tr>
<?
$filename = 'test.txt';
foreach ($studs as $v => $v2)
{
$content = $v.'=>'.$v2."\n";
?>
<tr>
<td><? echo $v.'</td><td>'.$v2 ?></td>
</tr>
<?
if (!$handle = fopen($filename, 'w')) {
print "Cannot open file ($filename)";
exit;
}
if (!fwrite($handle, $content)) {
print "Cannot write to file ($filename)";
exit;
}
fclose($handle);