我可以得到幫助,知道這是否可能嗎?我想選擇動態數組。php通過路徑選擇陣列
例如,
$oj = (object)['A' => (object)['B' => (object)['C' => (object)['D' => []]]]]
$E = 'A'
$oj->$E // this will work
$E = 'A->B'
$oj->$E // this will not work
除了寫一個完整的路徑我還有什麼可以做?或者,也許請告訴我,這是可能的,還是有任何我可以提及的例子?
$oj[A][B][C][D] <---NO
$oj->A->B->C->D <---NO
$E = A->B->C->D
$oj->E <--What I want
Question Update:
$oj->E = 'Store something' <-What I want, then will store into $oj.
//So E here is not pick up the value of D, but the path of D;
非常感謝。
尋找這個'$ oj [A [B [C [D]]]]'? – alfasin