Let's say I want to have a variable which should keep it's value.
<?php $files = array('file1.txt','file2.txt','file3.txt'); // list of the files to process $file = file_get_contents($files[$i]); process_the_file($file); $i++; exit();
So I'd like to process only one file per script run. And in my case the index of the currently processed file is
From my pont of view there are two methods available:
- Store variable in a file. I can serialise (and unserialize upon initialization) any data and store in a text file. However, I should keep an eye on the script termination to be sure that the needed values will be stored before the script terminated.
- Use database. It looks bulky and as previously described - I should keep an eye on storing.
So both of the methods looks too comlicated. Is there any better solution?