多维数组未定义索引

问题描述:

我编码一个Excel文件生成器。我需要从数据库中获得所有者的名字,然后为他们列出所有已完成的程序。当然,我想用一个计数器显示每个程序一次,这个计数器指出每个程序已经做了多少次。 我想这个代码做到这一点:多维数组未定义索引

// to get the list of owners 
$this->comms = $this->warehouse->getComms(); 

foreach($this->comms as $key=>$comm) 
{ 
    // producer/procedure [name] [counter] 
    $check1[] = array('comm'=>$comm->name, 'operations'=>array('operation'=>'', 'counter'=>0)); 

    // to get list of procedures for producer 
    $this->operations = $this->warehouse->getCommOperations($comm->id, $this->date_from_search, $this->date_to_search); 

    foreach($this->operations as $key=>$operation) 
    { 
     if(!in_array($operation->dsName, $check1[$comm->name]['operations']['operation'])) 
     { 
      $check1[$comm->name]['operations']=$operation->oService; 
      $check1[$comm->name][$operation->oService]['counter']++; 
     } 
     else 
     { 
      $check1[$comm->id][$operation->oService]['counter']++; 
     } 
    } 
} 

不幸的是我收到一个未定义指数:伊甸园警告&警告:in_array()预计参数2是数组中in_array检查行警告。我会非常感谢任何帮助。

问候!

+1

取代'$ CHECK1 [] =阵列( 'COMM' => $ comm-> name,'operations'=> ...'with'$ check1 [$ comm-> name] = array('operations'=> ...(如果$ comm-> name是唯一的,否则你必须用'array_search'改变'in_array') – fusion3k

foreach($this->operations as $key=>$operation) 
    { 
    if(is_array($check1[$comm->name]['operations']['operation'])) 
    { 
     if(!in_array($operation->dsName, $check1[$comm->name]['operations']['operation'])) 
    { 
     $check1[$comm->name]['operations']=$operation->oService; 
     $check1[$comm->name][$operation->oService]['counter']++; 
    } 
    } 
    else 
    { 
    $check1[$comm->id][$operation->oService]['counter']++; 
    } 
} 

写入in_array()之前使用is_array($ CHECK1 [$ comm->名] [ '操作'] [ '操作'])