I have 2 dimensions, such row=6 and col=5. The size can change.
How can I create an 2D empty array. Following approach is NOT what I am looking for, because it does not contains anything.
$arr = array(array());
How can I create an 2d array with dynamic size of "" values.
Many Thanks, BM
CodePudding user response:
This is how you can create a 2d array with a dynamic size
$array = array();
foreach ($rows as $row){
$array_values = array();
// Add as much values you want to add
array_push($array_values, '1');
array_push($array_values, '2');
array_push($array, $array_values);
}