Ken wrote:
[color=blue]
> How do I copy data from one file to another? from $_SESSION['fname'] to
> "fname"
>
> datafile.php has
>
> fname: $_SESSION['fname'];
> lname: $_SESSION['lname'];
>
> I would like to automatically copy the data to
>
> second.js
>
> var fname = "fname";
> var lname = "lname";
>
> to be used in JavaScript.
>
> I am familiar with
> $contents = file_get_contents($filename);
>
> and I know how to copy files but not data inside of the file.
>
> Thanks for the help.
>
> Ken[/color]
Hi Ken,
Have a look at:
http://nl2.php.net/manual/en/function.fopen.php
You will find a few examples and related functions over there.
It is not difficult.
1) Open a filehandle for the file to read.
2) Open a filehandle to the file to write to.
3) Walk though the first file and write stuff you want in the second file to
the second handle.
4) close both filehandles.
Good luck.
Regards,
Erwin Moller