我有这样的多维数组输出如下所示
我想组合pid
和使用任何分隔符的值,map
但不是相同的comma(,)
id
这是一个样本数据数组有超过 20000 个值,深度级别未知可能是 18 或 20
Array
(
[pid] => 10000
[map] => 11, 11
[id] => 5740
[parentId] => 5739
[text] => Text1
[children] => Array
(
[0] => Array
(
[pid] => 600
[map] =>
[id] => 5741
[parentId] => 5740
[text] => Adv
[children] => Array
(
[0] => Array
(
[pid] => 620
[map] => 115.43271636963, 28
[id] => 5745
[parentId] => 5741
[text] => Text1.1
)
[1] => Array
(
[pid] => 621
[map] => 1, 2
[id] => 5745
[parentId] => 5741
[text] => Text1.1
)
[2] => Array
(
[pid] => 1748
[map] => 11.43, 28
[id] => 5746
[parentId] => 5741
[text] => Text1.2
)
)
)
[1] => Array
(
[pid] => 700
[map] => 15, 17
[id] => 5750
[parentId] => 5740
[text] => Text2
[children] => Array
(
[0] => Array
(
[pid] => 500
[map] => 139.525390625, 35.797920227051
[id] => 5751
[parentId] => 5750
[text] => Text2.1
)
[1] => Array
(
[pid] => 502
[map] => 15, 17
[id] => 5751
[parentId] => 5750
[text] => Text2.1
)
[2] => Array
(
[pid] => 1157
[map] => 7.8320698738098, 48.023639678955
[id] => 5754
[parentId] => 5750
[text] => Text2.2
)
)
)
)
)
预期输出为。在这里我:
用作分隔符
Array
(
[pid] => 10000
[map] => 11, 11
[id] => 5740
[parentId] => 5739
[text] => Text1
[children] => Array
(
[0] => Array
(
[pid] => 600
[map] =>
[id] => 5741
[parentId] => 5740
[text] => Adv
[children] => Array
(
[0] => Array
(
[pid] => 620 : 621
[map] => 115.43271636963, 28 : 1, 2
[id] => 5745
[parentId] => 5741
[text] => Text1.1
)
[1] => Array
(
[pid] => 1748
[map] => 11.43, 28
[id] => 5746
[parentId] => 5741
[text] => Text1.2
)
)
)
[1] => Array
(
[pid] => 700
[map] => 15, 17
[id] => 5750
[parentId] => 5740
[text] => Text2
[children] => Array
(
[0] => Array
(
[pid] => 500 : 502
[map] => 139.525390625, 35.797920227051 : 15, 17
[id] => 5751
[parentId] => 5750
[text] => Text2.1
)
[1] => Array
(
[pid] => 1157
[map] => 7.8320698738098, 48.023639678955
[id] => 5754
[parentId] => 5750
[text] => Text2.2
)
)
)
)
)
我尝试了很多代码
其中一个功能是array_merge_recursive
还
function super_unique($array)
{
$result = array_map("unserialize", array_unique(array_map("serialize", $array)));
foreach ($result as $key => $value)
{
if ( is_array($value) )
{
$result[$key] = super_unique($value);
}
}
return $result;
}
我也试过这个解决方案检查这个
提前谢谢让我知道是否有任何功能