I have an array of objects coming from an Eloquent query:
[
{
"id": 1,
"user_id": 1,
"name": null,
"link": "storage/images/foo.png"
},
{
"id": 2,
"user_id": 1,
"name": null,
"link": "storage/images/foo.png"
},
{..}
]
In PHP, what would be the most efficient way to rename the "link" key to "url" in every object in the array? Keeping the same order of elements would be a bonus.
I'm hopeful to achieve this:
[
{
"id": 1,
"user_id": 1,
"name": null,
"url": "storage/images/foo.png"
},
{
"id": 2,
"user_id": 1,
"name": null,
"url": "storage/images/foo.png"
},
{..}
]