如果我在会话中有以下数组,我能否在每个 [cat] 中获取项目位置编号:
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.
)
)
例如,下面将给我第二个描述,但我如何得到它在 [cat] == 1 中的位置 #2(共 3 个):
$item = $_SESSION['questions'][2]->que;
实际的数组要大得多,并且有超过 1 个 [cat]。我试图得到的计数是每个这样的群体。