I have a function in my program to write an array to a text file, but every way I've tried results in the same result: when I open the file to check what's been written to it, all it displays is the word "Array" at the top. It's the last step I need to finish this assignment! I've tried a foreach loop, a listeach loop, and the simplest solution, shown below:
[PHP]function saveData($myFil e)
{
if($file = fopen("employee s.dat", "w")):
$numElements = count($myFile);
for($i = 0; $i < $numElements; $i++)
{
fwrite($file, $myFile[$i]);
}
fclose($file);
else:
echo("Error in opening file. Please re-submit");
echo("<A HREF ='gradedLab3.ht m'>Return to form</A>");
endif;
}[/PHP]
None of these has helped. Any advice?
[PHP]function saveData($myFil e)
{
if($file = fopen("employee s.dat", "w")):
$numElements = count($myFile);
for($i = 0; $i < $numElements; $i++)
{
fwrite($file, $myFile[$i]);
}
fclose($file);
else:
echo("Error in opening file. Please re-submit");
echo("<A HREF ='gradedLab3.ht m'>Return to form</A>");
endif;
}[/PHP]
None of these has helped. Any advice?
Comment