I need to sort an array by a specific "order" field, where within that array I have banners with the id, order, name, and img fields. I need to sort this array in order. the 0 order banner needs to come first, 1 second, and so on.
I need to sort an array by a specific "order" field, where within that array I have banners with the id, order, name, and img fields. I need to sort this array in order. the 0 order banner needs to come first, 1 second, and so on.
You can use the sortBy method of a Collection, to do this, create a Collection object from the array and order:
$collection = collect($array)->sortBy('ordem');
I hope it helps.