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 ce开发者_高级运维rtain size and THEN go back and fill it?
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';
You could use array_fill() for that:
$array = array_fill(1, 50, ""); // creates [1]...[50] with "" string
精彩评论