I've been searching and searching, trying and trying and I cannot get this to work accurately. Hopefully some of you PHP guru's can provide some advice?
I'm trying to increment the count of a two dimensional array element using the ++ operator. But if the element does not already exist the code throws and error. I know the error can be suppressed but that technique also suppresses all other errors as well. I first tried array_key_exists but that doesn't work on multi-dim arrays.
This error occurs with either incrementing or even just referencing in my code.
Here is the incrementing:
if (!isset($array["$key1"]["$key2])) { $array["$key1"]["$key2] = 0; }
$array["$key1"]["$key2]++;
and the output:
if (isset($array["$key1"]["$key2])) { print $array["$key1"]["$key2]; }
Hopefully someone who has run into this before can help?
Thank you . . .
I'm trying to increment the count of a two dimensional array element using the ++ operator. But if the element does not already exist the code throws and error. I know the error can be suppressed but that technique also suppresses all other errors as well. I first tried array_key_exists but that doesn't work on multi-dim arrays.
This error occurs with either incrementing or even just referencing in my code.
Here is the incrementing:
if (!isset($array["$key1"]["$key2])) { $array["$key1"]["$key2] = 0; }
$array["$key1"]["$key2]++;
and the output:
if (isset($array["$key1"]["$key2])) { print $array["$key1"]["$key2]; }
Hopefully someone who has run into this before can help?
Thank you . . .