From my C++ knowledge base, I tend to initialize arrays in PHP by typing:
$foo = array()
Or I may bring this custom from Javascript, anyway, is this of any use?
As there’s no problem in doing this:
$foo[45] = 'bar' without initializing it as an array, I guess not.
PS: the tags improvement is really good
Yes it is. At the very least in improves readability of code (so that you don’t need to wonder ‘where does
$foocome from? Is it empty, or is there anything in it?`.Also it will prevent
'Variable '$a' is not setnotices, orInvalid argument passed to foreachin case you don’t actually assign any values to array elements.