我有以下数组:
$allZones = array (
'header' => array('div1', 'div2'),
'content' => array('div3', 'div4')
);
我使用它通过以下方式创建实例:
foreach($allZones as $newZoneId => $newZoneSubs) {
$newZone = new zone($newZoneId, $newZoneSubs);
}
'zone' 类的构造函数如下所示:
public function __construct($newZoneId, array $newZoneSubs) {
$this->zoneId = $newZoneId;
if(is_array($newZoneSubs)) {
foreach($newZoneSubs as $newZoneSub) {
$this->zoneSubs[] = new zone($newZoneSub, '');
}
}
else {
echo "1: " . $newZoneSubs;
}
}
由于某种原因, $newZoneSubs 是空的。
谁能告诉我为什么?