I want to swap the content of two files using php. but it seems that the file executions are processed on the end of the script and in a strange way. because it always either write the content into only one file or nothing happens, but the files were rewritten.
i tried the following:
rename($file1,$file2_temp);
rename($file2,$file1); // replace the file1
rename($file2_temp,$file2); // save the temporary file2 as the file2
i also tried to put it into fopen and flock statements, but it didnt work.
does anyone have a solution for that?
i figured it out, The code was right, the problem was that my script runs twice somehow and therefor it was overwriting the files forth and back again 🙁
i now have to figure out why its running twice, but thanks to you all!