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.