I know that arrays are created dynamically, and creating them ahead of time isn't really necessary, but how would one do that with a 2D array? The same way?
(for$j) { for($i)     {     $array[j][i] = "data";     } }   Something like that? Obviously real for loops, of course.
1) Assigning it to a new empty array This is the fastest way to empty an array: a = []; This code assigned the array a to a new empty array. It works perfectly if you do not have any references to the original array.
PHP - Two-dimensional Arrays A two-dimensional array is an array of arrays (a three-dimensional array is an array of arrays of arrays).
At its absolute simplest, a 2D dimensional array can be created as:
<?php     $emptyArray = array(array()); ?>   Or as of PHP 5.4 you can also use:
<?php     $emptyArray = [[]]; ?> 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With