Let's say I have this array:
$array = array(
array("id" => 7867867, "animal" => "Dog"),
array("id" => 3452342, "animal" => "Lion"),
array("id" => 1231233, "animal" => "Lion"),
array("id" => 5867867, "animal" => "Dog"),
array("id" => 1111111, "animal" => "Zeebra"),
array("id" => 2222222, "animal" => "Cat"),
array("id" => 3333333, "animal" => "Cat"),
array("id" => 4444444, "animal" => "Zeebra")
);
Now what I've been trying to do is use php sort functions to be able to sort it based on specific rules (not alphabetical)
The client wants this information sorted by "Lion first, Dog second, Zeebra third, Cat fourth".
Something like this:
$array = array(
array("id" => 3452342, "animal" => "Lion"),
array("id" => 1231233, "animal" => "Lion"),
array("id" => 7867867, "animal" => "Dog"),
array("id" => 5867867, "animal" => "Dog"),
array("id" => 4444444, "animal" => "Zeebra"),
array("id" => 1111111, "animal" => "Zeebra"),
array("id" => 2222222, "animal" => "Cat"),
array("id" => 3333333, "animal" => "Cat"),
);
The array would be sorted using the "animal" value and would be based on pre-determined rules.
I was trying to figure out php sort functions but I could only get those to work with sorting the arrays alphabetically or numerically.
What I've gotten to work is a block of if-statements and loops, and I would like to get rid of that slow code as soon as I can.