On the PHP documentation page for arrays, the example code given is the following:
<?php
$array = array(
"foo" => "bar",
"bar" => "foo",
);
// as of PHP 5.4
$array = [
"foo" => "bar",
"bar" => "foo",
];
?>
Does that mean that the first code is invalid in PHP 5.4, or is the second code just an alternative?
The first code is still valid. The second notation is just a shorter and more convenient alternative.