I’ve been trying to find a solution for this one for the last couple of hours.
I have this multidimensional array:
Array
(
[0] => stdClass Object
(
[id] => 128
[itemID] => 27
[attribute] => xxx
)
[1] => stdClass Object
(
[id] => 129
[itemID] => 27
[attribute] => xxx
)
[2] => stdClass Object
(
[id] => 130
[itemID] => 27
[attribute] => xxx
)
[3] => stdClass Object
(
[id] => 131
[itemID] => 27
[attribute] => xxx
)
[4] => stdClass Object
(
[id] => 132
[itemID] => 27
[attribute] => xxx
)
[5] => stdClass Object
(
[id] => 133
[itemID] => 27
[attribute] => yyy
)
[6] => stdClass Object
(
[id] => 134
[itemID] => 27
[attribute] => xxx
)
)
As you can see obj. 5 has the attribute key to ‘yyy’.
I would like to bring to front this object which contains the attribute key of ‘yyy’ like a re-order so when i foreach, the yyy result to be first.
I have tried with different snippets found online but couldn’t find one that help me.
Given your array above: