如果我有一个包含的数组,是否有任何方法可以在不使用循环或 eval()的情况下['key1', 'key2', 'key3']
将其映射到数组?$array['key1']['key2']['key3']
数组示例:
$var = [
'key1' => [
'subkey1' => [
'finalkey' => 'value',
],
'subkey' => [
'otherkey' => 'value',
],
],
'key2' => 'blah'
];
然后我有一个这样的数组:
$keys = ['key1', 'subkey1', 'finalkey']
或者
$keys = ['key1', 'subkey']