How would I run a function on an array change? For example, whenever I read, write, or whatever with an array ($_SESSION) I want to run a function (which will set a variable inside the session array, but I do not want this to run the function as well).
I need to do this because I plan to make a timestamp that updates whenever the array $_SESSION is used. Is this possible?
For example:
session_start();
$_SESSION["foo"] = "bar"; //run the function!
$foo = $_SESSION["foo"]; //run the function! (optional, though preferred)
The function would be something like this:
$_SESSION["timestamp"] = time(); //do not run the function!
Thanks for any suggestions!
__set()and__get()magic methods, which can be used when setting or getting properties.