我有一个组数组和成员数组。Group_one 可以是成员、管理员等
//groups:
Array
(
[0] => Array
(
[id] => 1
...
[name] => Group_one
...
)
[1] => Array
(
[id] => 2
...
[name] => Group_two
...
)
...
//members:
CI_DB_mysql_result Object
(
[conn_id] => Resource id #12
[result_id] => Resource id #55
[result_array] => Array
(
[0] => Array
(
[id] => 2
...
[group] => Group_2
[group_id] => 2
)
[1] => Array
(
[id] => 5
...
[group] => Group_four
[group_id] => 4
)
...
现在我想计算 Group_one、Group_two 等中有多少。
我尝试了以下但不工作。
foreach($groups as $group)
{
foreach ($members->result_array() as $key => $list)
{
if($group['id']==$list['group_id'])
{
$stack[] = array();
array_push($stack,$list);
}
}
}
echo "<pre>stack is:";
//print_r($stack);
echo count($stack);
echo"</pre>end of stack";