I want to make a single function for set_error_handler() to deal with undefined indexes in an array with a specific name. For instance, the array is called: $products. If I have
$products = array(1 => 'a', 2 => 'b' // etc...
and later execute call:
$a = $products[0];
I get an error. I want to handle the error only for the array with the name $products and no other. How can I make that?
Please don't give me alternatives to this method of solving the problem. I already had a discussion about that and it was decided that it really is better to use this method. I must also warn that this is a super simplification of the real thing. I have already tried doing some research and nothing helped.
ArrayAccessSPL Interface? Just saying, because the error handler is not able to tell you that it's about a specific variable. Maybe you should share more of your problem that you actually hide?