I am using php script to read files containing lines of text. In the actual case, I will have files names as file1.txt, file2.txt, file3.txt and so on, probably with file4.doc etc. All the files are stored in same folder as phpscript one.
I want this to happen when I execute the script:
1. Script search for first file with .txt extension
The script will have to retrieve the filename as well, I know if only 1 file was read directly it would be fopen('file1.txt'), but in this case the script will read the files dynamically, thus each time it will execute a new file will be read, so will be like each time it gets a new file it will concatenate the name + ext and then use fopen('fileX.txt'). (using cron here to execute script)
2. Read content line-by-line for that file using fgets
3. [some processing will be done] //no code needed for this part
4. Delete the file read once EoF reached
5. When cron is read again, the script will be assumed to search for next .txt file, e.g. file2.txt, and will repeat steps 1-4 again.
Anyone can help me with the code for steps 1,2,4?