Hello world,
this is a very basic operation which i do almost every day and of course you can do it in different ways like always in programming. It's however not for absolute beginners. You need to have some basic knowledge about variables, functions etc. Please visit php.net for these basics, their online documenttation is one of the best of all languages i've worked with.
here is an example how you could do it:
<?php
# OPEN A FILE IN READ ONLY AND PUT RESULT INTO A FILE HANDLER ($FH)
$fh = fopen("/tmp/openme.txt", "r");
Possibiliy 1:
# READ CONTENT AS ONE BIG TEXT STRING FROM FILE HANDLER
$content = file_get_contents($fh);
Possibility 2:
# READ FILE AS AN ARRAY (EVERY LINE GOES TO ONE ARRAY ENTRY)
$content = file($fh);
# IF READ AS AN ARRAY YOU NEED FIRST TO CONVERT THE
# ARRAY INTO A STRING BEFORE SAVING
$content = implode("", $content);
# CREATE A NEW FILE OR OPEN FILE IN WRITE MODE AND GIVE IT
# A NEW FILE HANDLER ($FH_NEW)
$fh_new = fopen("/tmp/saveme.txt", "w");
# NOW STORE THE CONTENT IN THERE
fwrite($content, $fh_new);
# AND DO NOT FORGET TO CLOSE THE FILE AFTERWARDS TO MAKE YOUR FILE PERMANENT
fclose($fh_new);
?>
So, that's it. Hope this helped some of you people out there.