可能重复:
PHP 在保留键的同时遍历多维数组
我有一个像这样的深数组:
array {
["key1"] => "A"
["key2"] => "B"
["key3"] => array {
["subkey1"] => "C"
["subkey2"] => array {
["subsubkey1"] => "D"
}
}
}
我不知道这个数组会有多深。现在我想将其转换为如下所示的数组:
array {
array {
["key1"] => "A"
["key2"] => "B"
["key3.subkey1"] => "C"
["key3.subkey2.subsubkey1"] = > "D"
}
我该怎么做?我想它需要一个递归?