+ 2

How to copy whole content of one file to another file in PHP...??

14th Nov 2016, 4:24 PM
Kartik Bhat
Kartik Bhat - avatar
5 Answers
+ 7
It convert all data of a file in array, use file_get_content() it return a string. Moreover I was talking about easy and fast method, file cannot be fast and good in all cases. Thats why there are many function in PHP to do same thing
15th Nov 2016, 3:01 AM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 3
Have a look here: //Get all the content from the file $fileContents = file_get_contents('1.txt'); //Output to new file $fh = fopen('output.txt', 'w+'); foreach ($matches as $match) { fputs($fh, $match."\r\n"); //now put the copied content in this new file } fclose($fh);
24th Nov 2016, 6:36 AM
Nazrul Kabir
Nazrul Kabir - avatar
+ 2
well it depends upon which type of file binary or text and what it's size, tell me I will give you answer
14th Nov 2016, 4:29 PM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 2
i got some clue by thay "file()" function
14th Nov 2016, 5:13 PM
Kartik Bhat
Kartik Bhat - avatar
+ 2
i am asking about anykind of files.......
14th Nov 2016, 5:14 PM
Kartik Bhat
Kartik Bhat - avatar