Sum and group a PHP array

I have a multidimensional array and I want to be able to group by "PartNumber" and sum of "PartNumber". I'm fairly new to PHP arrays and I have been struggling with this one...

[value] => Array
        (
            [0] => Array
                (
                    [Reference] => SO2011-0012
                    [TypeId] => 1
                    [Lines] => Array
                        (
                            [0] => Array
                                (
                                    [Quantity] => 1
                                    [Item] => Array
                                        (
                                            [PartNumber] => OKIW9431
                                            [Description] => OKI 12 month warranty extension - 9431
                                            [CategoryId] => 4
                                            [Category] => Array
                                                (
                                                    [Name] => OKI Equipment
                                                )

                                        )

                                )

                        )

                    [Type] => Array
                        (
                            [Name] => Equipment 
                        )

                    [CustomerShipTo] => Array
                        (
                            [Name] => Eamon Lynch t/a Ace Printers
                        )

                )

            [1] => Array
                (
                    [Reference] => SO2010-0216
                    [TypeId] => 2
                    [Lines] => Array
                        (
                            [0] => Array
                                (
                                    [Quantity] => 1
                                    [Item] => Array
                                        (
                                            [PartNumber] => TN619XC
                                            [Description] => Cyan Toner - C2060/3070
                                            [CategoryId] => 28
                                            [Category] => Array
                                                (
                                                    [Name] => Develop Toner
                                                )

                                        )

                                )

                            [1] => Array
                                (
                                    [Quantity] => 3
                                    [Item] => Array
                                        (
                                            [PartNumber] => TN619XK
                                            [Description] => Black Toner - C2060/3070
                                            [CategoryId] => 28
                                            [Category] => Array
                                                (
                                                    [Name] => Develop Toner
                                                )

                                        )

                                )

                            [2] => Array
                                (
                                    [Quantity] => 1
                                    [Item] => Array
                                        (
                                            [PartNumber] => TN619XM
                                            [Description] => Magenta Toner - C2060/3070
                                            [CategoryId] => 28
                                            [Category] => Array
                                                (
                                                    [Name] => Develop Toner
                                                )

                                        )

                                )

                            [3] => Array
                                (
                                    [Quantity] => 1
                                    [Item] => Array
                                        (
                                            [PartNumber] => TN619XY
                                            [Description] => Yellow Toner - C2060/3070
                                            [CategoryId] => 28
                                            [Category] => Array
                                                (
                                                    [Name] => Develop Toner
                                                )

                                        )

                                )

                        )

Answers 0

Related Articles