How to store values from foreach loop into an array?

前端 未结 8 907
我在风中等你
我在风中等你 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:31

    this question seem quite old but incase you come pass it, you can use the PHP inbuilt function array_push() to push data in an array using the example below.

     $username) {
            array_push($item, $username);
        }
        print_r($items);
    ?>
    

提交回复
热议问题