This question already has an answer here:
- How can I sort arrays and data in PHP? 10 answers
Ok, I am sure that this has already been answered somewhere and I apologise for posting such a fundamental question, but I can't seem to find the answer anywhere... I'm only just dipping my big toe into php for the first time and spend most of my time in Javascript, so be nice to me :-)
I have an array of objects that is of the structure:
[
{
title: 'one',
type: 'cat'
},
{
title: 'two',
type: 'dog'
},
{
title: 'three',
type: 'snake'
},
{
title: 'four',
type: 'dog'
}
]
And I'd like to order them in the order ['dog', 'snake', 'cat]
so I get:
[
{
title: 'two',
type: 'dog'
}
{
title: 'four',
type: 'dog'
},
{
title: 'three',
type: 'snake'
},
{
title: 'one',
type: 'cat'
}
]
How do I do this?
</div>