我正在尝试使用此代码提取数组,但它给出了该错误。但是,如果我从代码中删除 while 块并且只给出索引,它就可以工作。这是代码。
//This function gives error: Notice: Undefined offset: 1 in .......
//but if i delete while block and only write print $type[$i]; it works.
public function checkMimeType(){
echo '<pre>';
$i = 0;
$type = array();
foreach($this->_sourceFile as $key){
$type= $key['type'];
}
while($i <= count($type))
{
print $type[$i].'<br>';
$i++;
}
}