I'm trying to sort the array below, by id with a custom order, preferably by creating an array (2177,1073,2951)
. I've attempted to use various PHP functions, but can't figure out how to specify a custom order. The data is returned via an API in a random order, and I need it sorted so I can use it.
{
"data": {
"people": [
{
"id": "1073",
"name": "rob",
},
{
"id": "2951",
"name": "cam",
},
{
"id": "2177",
"name": "mike",
}
]
}
}
I want to turn the above into this:
{
"data": {
"people": [
{
"id": "2177",
"name": "mike",
},
{
"id": "1073",
"name": "rob",
},
{
"id": "2951",
"name": "cam",
}
]
}
}