How to store values from foreach loop into an array?

前端 未结 8 900
我在风中等你
我在风中等你 2020-11-29 16:16

Need to store values from foreach loop into an array, need help doing that.

The code below does not work, only stores the last value, tried $items .= ...,

8条回答
  •  误落风尘
    2020-11-29 16:40

    $items=array(); 
    $j=0; 
    
    foreach($group_membership as $i => $username){ 
        $items[$j++]=$username; 
    }
    

    Just try the above in your code .

提交回复
热议问题