dongpou1935 2019-04-24 15:24
浏览 6

使用ArrayAccess :: getOffset计算调用次数

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 关于大棚监测的pcb板设计
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用