Ask for the same value extraction and classification in the multi-dimensional array in PHP

example PHP has such a multi-dimensional array

Array[4][
  {
    "attr_id": "11",
    "attr_price": "29.8",
    "attr_value": "",
    "goods_attr_id": "31",
    "goods_id": "10"
  },{
    "attr_id": "8",
    "attr_price": "29.8",
    "attr_value": "60CM",
    "goods_attr_id": "29",
    "goods_id": "10"
  },{
    "attr_id": "8",
    "attr_price": "29.8",
    "attr_value": "70CM",
    "goods_attr_id": "30",
    "goods_id": "10"
  },{
    "attr_id": "11",
    "attr_price": "29.8",
    "attr_value": "",
    "goods_attr_id": "28",
    "goods_id": "10"
  }
]

ask for advice on how to extract the same "attr_id" into a new array such as:

$arr = new arrry();
$arr["a"] = [
  {
    "attr_id": "8",
    "attr_price": "29.8",
    "attr_value": "70CM",
    "goods_attr_id": "30",
    "goods_id": "10"
  },{
    "attr_id": "8",
    "attr_price": "29.8",
    "attr_value": "70CM",
    "goods_attr_id": "30",
    "goods_id": "10"
  },
]

$arr["b"] = [
   {
    "attr_id": "11",
    "attr_price": "29.8",
    "attr_value": "",
    "goods_attr_id": "31",
    "goods_id": "10"
    },{
    "attr_id": "11",
    "attr_price": "29.8",
    "attr_value": "",
    "goods_attr_id": "28",
    "goods_id": "10"
  }
]

the length of the array is uncertain, the attr_ id value and the number are uncertain, which is to judge that the same attr_id in the array will be put into the new array.

Php
Mar.13,2021

$arr = [
    [
        "attr_id": "11",
        "attr_price": "29.8",
        "attr_value": "",
        "goods_attr_id": "31",
        "goods_id": "10"
    ],
    [
        "attr_id": "8",
        "attr_price": "29.8",
        "attr_value": "60CM",
        "goods_attr_id": "29",
        "goods_id": "10"
    ],
    [
        "attr_id": "8",
        "attr_price": "29.8",
        "attr_value": "70CM",
        "goods_attr_id": "30",
        "goods_id": "10"
    ],
    [
        "attr_id": "11",
        "attr_price": "29.8",
        "attr_value": "",
        "goods_attr_id": "28",
        "goods_id": "10"
    ]
]

$arr1 = [];
foreach ($arr as $k => $v) {
    $arr1[$v[attr_id]][] = $v;
}

// 
$arr1 = [
    '8' => [
        [
            "attr_id": "8",
            "attr_price": "29.8",
            "attr_value": "70CM",
            "goods_attr_id": "30",
            "goods_id": "10"
        ],
        [
            "attr_id": "8",
            "attr_price": "29.8",
            "attr_value": "60CM",
            "goods_attr_id": "30",
            "goods_id": "10"
        ],
    ],
    '11' => [
        [
            "attr_id": "11",
            "attr_price": "29.8",
            "attr_value": "",
            "goods_attr_id": "31",
            "goods_id": "10"
        ],
        [
            "attr_id": "11",
            "attr_price": "29.8",
            "attr_value": "",
            "goods_attr_id": "28",
            "goods_id": "10"
        ],
    ],
]
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31293-402fd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31293-402fd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?