Forum Moderators: coopster
I have a text file called data.txt that has one line of data with a number in it e.g. 500, basically i need a code that will read the first line of data.txt and store it as a variable e.g. $data = data and + 1 to the actual data.txt file. so this way the data.txt becomes 501 but the variable for the user is 500.
Its just like a counter.
Thanx in advanced
$file = "/path/to/file.text";
$data = file_get_contents [php.net]($file);
$data2 = $data + 1;
$handle = fopen [php.net]($file, "w");
fwrite [php.net]($handle, $data2);
fclose($handle);
You will have to chmod the text file to allow it to be written to.