My constructor is empty, so no recursive screw up there 🙂 I know the code is working as it will output stuff before the server rolls over and dies - i found out today from the sysadmin that the process was terminated because it ate too much memory. Hehe.
So, as an alternative I though about writing the values (objects) to a file rather than an array in memory. Then in my 2nd method re-read in the file a value (object) at a time and do the processing.
My question is.....
what is the best way to store an object on the hdd, and then read it back in?
I started with some code like this for saving:-
fwrite($file_store, serialize($readitem));
Where $readitem is an instance of a class. However how do I read JUST that value/object back in, when the file contains many of them one after another? The fread() function requires lengths to read in and I'm not going to know that.
Would simply writing an EOL after each fwrite() work, if i can somehow read data up to an EOL character later?
Maybe somebody has written a simple class to do this already? I've only briefly searched but found only one thing which stored everything in memory before writing it to a file at the end, which defeats my point in doing the whole file writing thing
🙁