Throughout the code i'm working on we extensively use a multi-dimensional array and i'm trying to count how many times we call the array on a given page.
Example: $config['emails']['sendto']
I've changed $config to be an ArrayAccess object and i'm using getOffset to increment a counter, something like this:
function getOffset($offset) {
$this->counter->increment[$offset] = array(
'files' => array(
'filename:line' = counter
)
)
}
I have also made each child the same object. So each time i call getOffset the counter is updated. BUT i've got an issue.
When i access: $config['emails']['sendto'] i want the counter to look like this
$counter['emails'] = array(
"sendto" => array(
"files" => array(
"index.php:190" = 1,
"mail.php:348" = 100
)
)
)
But instead it looks like this
array(
"emails" =>
"files" => array(
"index.php:190" = 1,
"mail.php:348" = 100
)
),
"sendto" =>
"files" => array(
"index.php:190" = 1,
"mail.php:348" = 100
)
),
)
So, what i want is the child arrayaccess object to know that it's a child. But i cant figure it out. Can anyone point my in any direction please.