我一直在使用字符串偏移量访问数组时出错。数组看起来像这样:
$array = array(
"first" => array("one","two","three"),
"second" => array("blabla"),
"third" => array("something","else"),
"fourth" => array("next","nextnext","nextnextnext")
);
我正在尝试根据我拥有的字符串获取内部数组之一,并使用该字符串作为偏移量,如下所示:
$curArray = $array[$this->string];
但是每次我运行脚本时,我都会在该行出现错误。你能告诉我为什么吗?我得到的错误是“非法偏移类型”。谢谢