My array:
Array
(
[0] => stdClass Object
(
[questionID] => 588
[answer] => extremely-likely
[count] => 2
[percent] => 95%
)
[1] => stdClass Object
(
[questionID] => 588
[answer] => extremely-unlikely
[count] => 2
[percent] => 95%
)
[2] => stdClass Object
(
[questionID] => 588
[answer] => likely
[count] => 1
[percent] => 48%
)
[3] => stdClass Object
(
[questionID] => 588
[answer] => neither
[count] => 1
[percent] => 48%
)
[4] => stdClass Object
(
[questionID] => 588
[answer] => unsure
[count] => 1
[percent] => 48%
)
)
I have managed to pull back the data I want to display however, when I loop through each of my questions I want to display them in a specific order.
The order is:
Extremely Likely
Likely
Neither
Unlikely
Extremely unlikely
Unsure
This is because I want my table to look like below:
But at the moment it looks like this.
Sometimes not all of these questions will be there, so if someone hasn't answered extremely likely then that will not be in the array. In that case it will need to default to the next in the list.