If I have id number and an array in the following format, how do I find out what count (position number) ‘Red’ among all other items where cat == 4? The answer I am looking for #3 of 4.
Array
(
[0] => stdClass Object
(
[id] => 1
[cat] => 1
[que] => Description here.
)
[1] => stdClass Object
(
[id] => 2
[cat] => 1
[que] => Description here.
)
[2] => stdClass Object
(
[id] => 3
[cat] => 1
[que] => Description here.
)
....
[31] => stdClass Object
(
[id] => 32
[cat] => 4
[que] => Description here.
)
[32] => stdClass Object
(
[id] => 33
[cat] => 4
[que] => Description here.
)
[33] => stdClass Object
(
[id] => 34
[cat] => 4
[que] => Red.
)
[34] => stdClass Object
(
[id] => 35
[cat] => 4
[que] => Description here.
)
)
Do I need to split array and then loop? Lost…
——— EDIT ———-
OK, I did a bad job explaining…
What I meant was: there are many objects withing this array. They are broken into groups, categories. [cat] is the value for each group. There are multiple items in each group. What I was hoping to get was a number of items in each group and the position of particular item withing that group, for example: 4 out of 12.
(Revised to count all categories)