很抱歉這么長的描述,但我已經為合并多個多維關聯數組苦苦掙扎了一天多了。任何人都可以建議實現這一目標的優(yōu)化方法。我想根據所需的結果創(chuàng)建 HTML 列表。請參閱當前列表的附加圖像。但我想將孩子合并為共同的父母。陣列 1:Array( [cat_id] => 1 [parent_cat_id] => 0 [cat_name] => Collectables [children] => Array ( [cat_id] => 1335 [parent_cat_id] => 1 [cat_name] => Animal Collectables [children] => Array ( [cat_id] => 10811 [parent_cat_id] => 1335 [cat_name] => Bird Collectables [children] => Array ( [cat_id] => 37847 [parent_cat_id] => 10811 [cat_name] => Bluebird ) ) ))陣列 2:Array( [cat_id] => 1 [parent_cat_id] => 0 [cat_name] => Collectables [children] => Array ( [cat_id] => 1335 [parent_cat_id] => 1 [cat_name] => Animal Collectables [children] => Array ( [cat_id] => 10811 [parent_cat_id] => 1335 [cat_name] => Bird Collectables [children] => Array ( [cat_id] => 37848 [parent_cat_id] => 10811 [cat_name] => Hummingbird ) ) ))我希望結果保持原樣,并在同一級別創(chuàng)建另一個子數組子數組,如下所示。Array( [cat_id] => 1 [parent_cat_id] => 0 [cat_name] => Collectables [children] => Array ( [cat_id] => 1335 [parent_cat_id] => 1 [cat_name] => Animal Collectables [children] => Array ( [cat_id] => 10811 [parent_cat_id] => 1335 [cat_name] => Bird Collectables [children] => Array ( [0] => Array( [cat_id] => 37847 [parent_cat_id] => 10811 [cat_name] => Bluebird ) [1] => Array( [cat_id] => 37848 [parent_cat_id] => 10811 [cat_name] => Hummingbird ) ) ) ))[1]:當前列表:https ://i.stack.imgur.com/p4F0X.png
PHP Merge multiple multi-dimensional
30秒到達戰(zhàn)場
2023-05-12 14:50:34