My question is how to get or split an array by year using in array key date by ascending order,
I've tried many... but I didn't get it,
[
{
"id": "47",
"date": "07/16/2022",
"text": "ph"
}
{
"id": "46",
"date": "06/16/2022",
"text": "ph"
},
{
"id": "45",
"date": "06/16/2021",
"text": "ph"
}]
And the output I need is,
[
"2021": [{
"id": "45",
"date": "06/16/2021",
"text": "ph"
}],
"2022": [{
"id": "46",
"date": "06/16/2022",
"text": "ph"
},
{
"id": "47",
"date": "07/16/2022",
"text": "ip"
}]
]
How to do it in either PHP or JavaScript?