0
我讀到會議包裝方式和存在方式:PHP(7)動態會話數據檢索
/*
to set something like $_SESSION['key1']['key2']['key3']:
$session->setMd(array('key1', 'key2', 'key3'), 'value')
*/
public function setMd($keyArray, $val)
{
$arrStr = "['".implode("']['", $keyArray)."']";
$_SESSION{$arrStr} = $val;
}
這正是我需要的,但是當我試圖用這種方式如下:
$this->path = ['a','bb','ccc'];
$this->_sessionStorage{"['".implode("']['",$this->path)."']"} = 'dddd';
ddd($this->_sessionStorage);
我得到這樣的輸出:
array(1) {
["['a']['bb']['ccc']"]=>
string(4) "dddd"
}
這是假的還是我做錯了什麼?