Question: 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?

Answer: 
The first code is still valid. The second notation is just a shorter and more convenient alternative.
As others noted the first one is valid. The second one is shorter version.

Here are the pros and cons for second version:

> 
> 
> ```
> Pro
> 
>   Good for framework development when dealing with long parameterlists
>   Other web languages have similar syntax
>   Readable
> 
> Contra
> 
>   Yet another alias
>   Would take distinctness from []
>   Not searchable through search engines
>   Unreadable
>   Patch may be difficult to maintain in future
> 
> ```
> 
> 

from [PHPWiki](https://wiki.php.net/rfc/shortsyntaxforarrays)