Hi,
1) I don't know why you have so many \ (backslash) characters before the quotes?
2) Anyway, The reason it is not working is because you are calling fopen every time you run through the loop. When you call fopen with the "w" argument, it removes the file first if it already exists and creates a new one. When you run through the look and open the file every time you are writing a line, only your last line would get inserted into the file.
Here is what I suggest:
- move the fopen() code OUTside the for() loop
- move the fclose() code outside the for
so it will look something like this:
$fd = fopen("file.txt", "w");
for(....) {
...some code...
...fwrite....
}
fclose($fd);
hope this helps,
-sridhar
P.S. If you want to know how I learnt PHP, it was through online tutorials and basically looking at the manual and other people's code. I found books ABSOLUTELY useless. maybe other disagree, but give the online content a try first before buying books :-)