Answers for "use array push in a foreach loop php"

PHP
1

array push foreach php

$items = array();
foreach($group_membership as $username) {
 $items[] = $username;
}

print_r($items);
Posted by: Guest on September-02-2020
0

php assign an array inside a foreach loop

$input = array("teamA","teamB","teamC");
$data = [];
foreach($input as $value){
    $assign = "50"; /* The data just temp */
    $data[$value] = $assign;
}

echo $data["teamA"];
Posted by: Guest on July-26-2021

Browse Popular Code Answers by Language