树形结构从末级的 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
                                        )

                                )

                        )

                )

        )

)
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
Epona
最佳答案

可以试试 array_reduce()方法

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

可以试试 array_reduce()方法

5年前 评论
jenkincei

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

5年前 评论

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