从现有数组创建新数组

时间:2019-12-09 12:03:32

标签: php arrays

我有一些类似这样的数据

[standardFeatures] => Array
                            (
                                [0] => Array
                                    (
                                        [description] => 2+2 Seating Arrangement
                                        [category] => Interior
                                    )

                                [1] => Array
                                    (
                                        [description] => 20in Alloy Wheels - 10 Spoke Gloss Black Non Diamond Turned
                                        [category] => Exterior
                                    )

                                [2] => Array
                                    (
                                        [description] => 6.5in LCD Screen
                                        [category] => Audio and Communications
                                    )

                                [3] => Array
                                    (
                                        [description] => A2DP Bluetooth Audio
                                        [category] => Audio and Communications
                                    )

                                [4] => Array
                                    (
                                        [description] => ABS - Anti Lock Braking System
                                        [category] => Safety and Security
                                    )

                                [5] => Array
                                    (
                                        [description] => AM-FM Radio
                                        [category] => Audio and Communications
                                    )

                                [6] => Array
                                    (
                                        [description] => Airbag - Curtain Side Head
                                        [category] => Safety and Security
                                    )

                                [7] => Array
                                    (
                                        [description] => Airbag - Pelvis and Thorax Seat Mounted
                                        [category] => Safety and Security
                                    )

                                [8] => Array
                                    (
                                        [description] => Alarm and Immobiliser
                                        [category] => Safety and Security
                                    )

                                [9] => Array
                                    (
                                        [description] => Automatic Temperature Control
                                        [category] => Interior
                                    )

                                [10] => Array
                                    (
                                        [description] => Bang & Olufsen BeoSound Audio 1000w
                                        [category] => Audio and Communications
                                    )

                                [11] => Array
                                    (
                                        [description] => Brake Calipers - Dark Grey Anodised
                                        [category] => Exterior
                                    )

                                [12] => Array
                                    (
                                        [description] => Bright Side Strakes
                                        [category] => Exterior
                                    )

                                [13] => Array
                                    (
                                        [description] => Carbon Fibre Door Mirror Arms
                                        [category] => Exterior
                                    )

                                [14] => Array
                                    (
                                        [description] => Centre Stack Rotaries - Satin Chrome
                                        [category] => Drivers Assistance
                                    )

                                [15] => Array
                                    (
                                        [description] => Cruise Control
                                        [category] => Drivers Assistance
                                    )

                                [16] => Array
                                    (
                                        [description] => DAB Radio
                                        [category] => Audio and Communications
                                    )

                                [17] => Array
                                    (
                                        [description] => DSC - Dynamic Stability Control
                                        [category] => Safety and Security
                                    )

                                [18] => Array
                                    (
                                        [description] => Daytime Running Lights
                                        [category] => Illumination
                                    )

                                [19] => Array
                                    (
                                        [description] => Door Mirrors - Powerfold and Heated
                                        [category] => Exterior
                                    )

                                [20] => Array
                                    (
                                        [description] => Dual-Stage Driver and Passenger Front Airbags
                                        [category] => Safety and Security
                                    )

                                [21] => Array
                                    (
                                        [description] => EBA - Emergency Brake Assist
                                        [category] => Safety and Security
                                    )

                                [22] => Array
                                    (
                                        [description] => EBD - Electronic Brakeforce Distribution
                                        [category] => Safety and Security
                                    )

                                [23] => Array
                                    (
                                        [description] => Electrically Operated Front Seats with Side Airbags
                                        [category] => Interior
                                    )

                                [24] => Array
                                    (
                                        [description] => Exhaust - Bright Chrome Finisher
                                        [category] => Exterior
                                    )

                                [25] => Array
                                    (
                                        [description] => Exposed Carbon Fibre Splitter - Diffuser - Sill Blade
                                        [category] => Exterior
                                    )

                                [26] => Array
                                    (
                                        [description] => Exterior Meshes - Titanium Silver
                                        [category] => Exterior
                                    )

                                [27] => Array
                                    (
                                        [description] => Front Electric Windows
                                        [category] => Exterior
                                    )

                                [28] => Array
                                    (
                                        [description] => Front Grille - Bright
                                        [category] => Exterior
                                    )

                                [29] => Array
                                    (
                                        [description] => Front and Rear Parking Sensors
                                        [category] => Drivers Assistance
                                    )

                                [30] => Array
                                    (
                                        [description] => Glass ECU
                                        [category] => Interior
                                    )

                                [31] => Array
                                    (
                                        [description] => HBA - Hydraulic Brake Assist
                                        [category] => Safety and Security
                                    )

                                [32] => Array
                                    (
                                        [description] => Hardware Pack - Iridium
                                        [category] => Interior
                                    )

                                [33] => Array
                                    (
                                        [description] => Headlining - Rokona
                                        [category] => Interior
                                    )

                                [34] => Array
                                    (
                                        [description] => Headrest Embroidery - Vanquish S Logo
                                        [category] => Interior
                                    )

                                [35] => Array
                                    (
                                        [description] => Heated Front Seats
                                        [category] => Interior
                                    )

                                [36] => Array
                                    (
                                        [description] => Heated Rear Screen
                                        [category] => Exterior
                                    )

                                [37] => Array
                                    (
                                        [description] => Infotainment System AMi III - with Capacitive Switching
                                        [category] => Audio and Communications
                                    )

                                [38] => Array
                                    (
                                        [description] => Interior Pack - Jewellery Satin Chrome
                                        [category] => Interior
                                    )

                                [39] => Array
                                    (
                                        [description] => LED Light Blade Tail Lamps
                                        [category] => Illumination
                                    )

                                [40] => Array
                                    (
                                        [description] => Laminated Windscreen with Clear Noise-Insulation Layer
                                        [category] => Exterior
                                    )

                                [41] => Array
                                    (
                                        [description] => Launch Control
                                        [category] => Performance
                                    )

                                [42] => Array
                                    (
                                        [description] => Memory Front Seats and Exterior Mirrors
                                        [category] => Interior
                                    )

                                [43] => Array
                                    (
                                        [description] => PTC - Positive Torque Control
                                        [category] => Performance
                                    )

                                [44] => Array
                                    (
                                        [description] => Primary Carpet Colours
                                        [category] => Interior
                                    )

                                [45] => Array
                                    (
                                        [description] => Remote Audio Control
                                        [category] => Interior
                                    )

                                [46] => Array
                                    (
                                        [description] => Remote-Control Central Door Locking and Boot Release
                                        [category] => Safety and Security
                                    )

                                [47] => Array
                                    (
                                        [description] => Reversing Camera
                                        [category] => Drivers Assistance
                                    )

                                [48] => Array
                                    (
                                        [description] => Satellite Navigation System - HDD
                                        [category] => Audio and Communications
                                    )

                                [49] => Array
                                    (
                                        [description] => Seat Belt Dual Pre-Tensioners and Digressive Load Limiters
                                        [category] => Safety and Security
                                    )

                                [50] => Array
                                    (
                                        [description] => Seatbelts - Warm Charcoal
                                        [category] => Safety and Security
                                    )

                                [51] => Array
                                    (
                                        [description] => Servotronic Speed-Sensitive Power-Assisted Steering
                                        [category] => Performance
                                    )

                                [52] => Array
                                    (
                                        [description] => Sill Plaques - Aluminium Vanquish S
                                        [category] => Interior
                                    )

                                [53] => Array
                                    (
                                        [description] => Single Bi-xenon Headlights
                                        [category] => Illumination
                                    )

                                [54] => Array
                                    (
                                        [description] => Sports Seats
                                        [category] => Interior
                                    )

                                [55] => Array
                                    (
                                        [description] => Steering Column Tilt and Reach Adjustment
                                        [category] => Interior
                                    )

                                [56] => Array
                                    (
                                        [description] => Steering Wheel - Black Round Full Leather Standard Stitching
                                        [category] => Interior
                                    )

                                [57] => Array
                                    (
                                        [description] => Suspension - 3 Stage Adaptive Damping
                                        [category] => Performance
                                    )

                                [58] => Array
                                    (
                                        [description] => TC - Traction Control
                                        [category] => Safety and Security
                                    )

                                [59] => Array
                                    (
                                        [description] => Trim Inlay - Iridium Fascia
                                        [category] => Interior
                                    )

                                [60] => Array
                                    (
                                        [description] => Trip Computer
                                        [category] => Drivers Assistance
                                    )

                                [61] => Array
                                    (
                                        [description] => Tyre Pressure Monitoring System
                                        [category] => Drivers Assistance
                                    )

                                [62] => Array
                                    (
                                        [description] => USB Connector
                                        [category] => Audio and Communications
                                    )

                                [63] => Array
                                    (
                                        [description] => Window Surround - Bright
                                        [category] => Exterior
                                    )

                                [64] => Array
                                    (
                                        [description] => iPhone Integration and Apple CarPlay
                                        [category] => Audio and Communications
                                    )

                            )

我想做的是为每个类别创建一个新的数组,然后将所有类别存储在一个数组中,

例如,我将拥有一个名为Interior的数组,并且该数组中所有键值为category => Interior的项都将存储在其中,我知道我可以对其进行循环执行,但是我想知道是否还有更简洁的方法吗?

0 个答案:

没有答案