最初的代碼如下:
$idIter=new ArrayIterator(array('01','02'));
$nameIter=new ArrayIterator(array('張三','李四'));
$mit=new MultipleIterator(MultipleIterator::MIT_KEYS_ASSOC);
$mit->attachIterator($idIter,'id');
$mit->attachIterator($nameIter,'name');
foreach($mit as $key=>$val)
{
print_r($val);
}
以上代碼會(huì)報(bào)warning錯(cuò)誤
但是,但我把$key刪除過(guò)后,就沒(méi)問(wèn)題了~
$idIter=new ArrayIterator(array('01','02'));
$nameIter=new ArrayIterator(array('張三','李四'));
$mit=new MultipleIterator(MultipleIterator::MIT_KEYS_ASSOC);
$mit->attachIterator($idIter,'id');
$mit->attachIterator($nameIter,'name');
foreach($mit as $val)
{
print_r($val);
}