Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP declaring empty arrays?

I have to make a two-dimensional array based on the number of lets say car parts that is submitted on a form. Is it possible to declare an array of a certain size and THEN go back and fill it?

like image 715
nkcmr Avatar asked Dec 12 '22 15:12

nkcmr


1 Answers

PHP arrays are dynamically allocated. There's no reason to create it ahead of time. Just start using the indexes as you need them:

$myNewVar[0] = 'data';
like image 129
mellamokb Avatar answered Dec 15 '22 05:12

mellamokb