Just wishing to quickly verify this. It is different from my immediate experience from other languages whereby an array must first be declared before it can be filled with values.
Yes, PHP will automatically create an array given any of the following
$foo[] = $bar;
$foo[1] = $bar;
$foo['bar'] = $bar;
// and of course
$foo = array();
// and soon to pass
$foo = [1, 2, 3];
PHP will create the array even without being implicitly declared, yes.
$array[] = ...
$array would be a valid array.
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