0

This is my code that is causing the offset and I can't find out why.

 {
    /* menu set up */
    $arData = file($this->_sMenuFile);
    $index = 0;
    foreach($arData as $line) {
        //On this line is where the error is happening.                                                        
        list($level,$group,$label,$module,$file,$order,$width) = explode('|',trim($line));
        if($level == "top") $sGroup = $label;
        if(strlen($file) > 0) {
        $this->_arMenuItems['name'][$index] = $label;
        $this->_arMenuItems['group'][$index] = $sGroup;
        $this->_arMenuItems['module'][$index] = $module;
        $this->_arMenuItems['file'][$index] = $file;
        $index++;
    }
}
MH2K9
  • 11,951
  • 7
  • 32
  • 49
  • 1
    `On this line is where the error is happening.` it means there explode does not return array with 7 elements. – Cheery Oct 10 '14 at 17:26
  • If it is not obvious, you can do `print_r($line)` before the row with the explode and check how many elements are in the line. Or maybe just the delimiter is not `|`... – Antoan Milkov Oct 10 '14 at 17:47

1 Answers1

0

use this

  if($level == "top") $sGroup = $label;
  if(strlen($file)-1 > 0) {
    $this->_arMenuItems['name'][$index] = $label;
    $this->_arMenuItems['group'][$index] = $sGroup;
    $this->_arMenuItems['module'][$index] = $module;
    $this->_arMenuItems['file'][$index] = $file;
    $index++;
                        }
}
Harutyun Abgaryan
  • 2,013
  • 1
  • 12
  • 15