我有以下功能:
function define_field($placeholder,&$fields,$val)
{
$sections=preg_split("/\./",$placeholder);
if (count($sections)==0)
{
} else if (count($sections)==1)
{
$fields[$sections[0]]=$holder;
} else
{
$cur_holder=& $fields;
for($i=0;$i<count($sections)-1;$i++)
{
$part=$sections[$i];
if (isset($cur_holder[$part]))
$cur_holder=& $cur_holder[$part];
else
{
if ($i==0)
{
$fields[$part]=array(array());
$cur_holder=& $fields[$part];
} else
{
$cur_holder[$part]=array(array());
$cur_holder=& $cur_holder[$part];
}
}
}
$cur_holder[$sections[count($sections)-1]]=$holder;
}
}
我收到此警告:“不能在...中使用标量值作为数组”
这是警告线:
$cur_holder[$sections[count($sections)-1]]=$holder;
有人知道如何解决这个问题吗?