Sorting data with php

2

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.

    
asked by anonymous 21.09.2016 / 20:19

1 answer

2

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.

    
21.09.2016 / 20:29