【发布时间】:2013-11-15 15:34:18
【问题描述】:
我有一个非常复杂的多维数组 ($tree)。我收到那个大数组作为参考。
现在,我需要在其中找到某个键并在其中插入数据。
找到所需的密钥很容易。函数搜索数组并返回路径 $path。例如,它返回$path = array('index1', 'index2', 'index3')。这意味着,我需要分配像$tree['index1']['index2']['index3'] = $some_data_i_needed_to_insert 这样的数据。
现在问题出现了,我无法从我从 seach 函数收到的地址中处理该数组索引。
我试过这样:
<?php
$path = '[\'index1\'][\'index2\'][\'index3\']';
$tree{$path} = $some_data_i_needed_to_insert;
?>
在我的情况下,有没有办法解决数组索引?
【问题讨论】:
-
不清楚你在问什么。
-
我们能看到第一个函数吗?这可能有助于澄清问题所在。
-
你为什么要
$tree{'[1334][\'#below\'][3242]'}? -
更新了问题。抱歉不清楚。