我有一个数组:
$groups = BP_Groups_Member::get_group_ids( $user_id );
echo "<pre>";
var_dump($groups);
echo "</pre>";
with给出以下结果:
array(2) {
["groups"]=>
array(2) {
[0]=>
string(1) "6"
[1]=>
string(1) "5"
}
["total"]=>
int(2)
}
如何设置字符串“6”和“5”来设置company_id而不是“4”? 在示例中:首先,它应该显示所有头像,公司用户的链接“6”,然后在同一列表中显示公司的用户“5”
<?php if ( company_has_users('company_id=4 & exclude_admins_mods=false') ) : ?>
<ul id="user-list" class="item-list">
<?php while ( company_users() ) : company_the_user(); ?>
<li>
<?php company_user_avatar() ?>
<?php company_user_link() ?>
</li>
<?php endwhile; ?>
</ul>
<?php else: ?>
<div id="message" class="info">
<p>This company has no users.</p>
</div>
答案 0 :(得分:1)
检查此示例
<?php
$array = array(
"0"=>array(
"01"=>"test1",
"02"=>"test2"
)
,1=>"xyz");
echo "<pre>";
print_r($array);
foreach($array as $data)
{
// this will print each element of array
print_r($data);
}
//output will be
/*Array
(
[01] => test1
[02] => test2
)
xyz*/
?>