I will show you how PHP read / write file.
example.txt
PHP Code:
0
1
2
3
4
5
6
7
8
9
PHP Code:
<?php
// at first read content from file example.txt
$strFileName = "example.txt";
$objFopen = fopen($strFileName, 'r');
while (!feof($objFopen)) {
$lines[] = fgets($objFopen, 4096);
}
fclose($objFopen);
// now we will edit content from example.txt and write to a new file new_example.txt
$strFileName = "new_example.txt";
$objFopen = fopen($strFileName, 'w');
foreach ($lines as $k=>$v) {
fwrite($objFopen, ($v+1)."\r\n");
}
fclose($objFopen);
?>
output new_example.txt
PHP Code:
1
2
3
4
5
6
7
8
9
10
Hope this help.