-1

我有一个数组:

$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>
4

1 回答 1

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*/

?>
于 2013-09-23T05:23:35.573 回答