0

Can we declare the array's length first instead of directly input the data ?

set the length of the array

7th Feb 2017, 11:37 PM
Joshua Natan
Joshua Natan - avatar
3 Respuestas
0
Just fill the array with empty strings or 0s... example if you wants an array of length 10: <?php $cars = array(); for ($x = 0; $x <10; $x++) {     $cars[$x] = ""; }  ?>
8th Feb 2017, 5:53 AM
Sam
0
so technically we can't do like what we do in java ? String [] abc = new String [ length of the array]
8th Feb 2017, 8:45 AM
Joshua Natan
Joshua Natan - avatar
0
that's my understanding based on the way we initialize the array.
8th Feb 2017, 2:09 PM
Sam