树形结构从末级的 score 值往一级分类汇总

有精通算法的吗 太难了

Array
(
    [0] => Array
        (
            [ability_category_id] => 1
            [title] => 数理与科学
            [parent] => 0
            [combi] => 0-1
            [floor] => 1
            [child] => Array
                (
                    [0] => Array
                        (
                            [ability_category_id] => 56
                            [title] => 观察力
                            [parent] => 1
                            [combi] => 1-1-56
                            [floor] => 2
                            [child] => Array
                                (
                                    [0] => Array
                                        (
                                            [ability_category_id] => 57
                                            [title] => 社会科学一
                                            [parent] => 56
                                            [combi] => 2-1-56-57
                                            [floor] => 3
                                            [age] => 4-5
                                            [ability_id] => 609
                                            [score] => 3.330
                                            [norm_ability_id] => 611
                                            [norm_score] => 3.330
                                        )

                                    [1] => Array
                                        (
                                            [ability_category_id] => 58
                                            [title] => 生命科学一
                                            [parent] => 56
                                            [combi] => 2-1-56-58
                                            [floor] => 3
                                            [age] => 4-5
                                            [ability_id] => 612
                                           [score] => 3.330
                                            [norm_ability_id] => 612
                                            [norm_score] => 3.330
                                        )

                                )

                        )

                )

        )

)
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
Epona
最佳答案

可以试试 array_reduce()方法

4年前 评论
讨论数量: 2
Epona

可以试试 array_reduce()方法

4年前 评论
jenkincei

试试这个吧 ClosureTable,适合各种操作,
https://github.com/jiaxincui/closure-table

4年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!