Kurzschreibweise für Arrays ab PHP 5.4
In anderen Programmiersprachen gibt es die Kurzschreibweise für Arrays ja schon etwas länger. In PHP muss man darauf verzichten, doch mit PHP 5.4 ändert sich das.
Am Samstag hatte Pierre Joyce via Twitter bekannt gegeben, dass die “Short array syntax” ab sofort im SVN von PHP 5.4 verfügbar ist.
Short array syntax support is now in SVN, #php 5.4+, http://is.gd/NFSTpn snaps with rev. 313641 or higher should follow (src or bins snaps).
Normale Syntax für Arrays in PHP:
$foo = array('foo', 'bar'); print_r($foo); Array ( [0] => foo [1] => bar ) $bar = array('foo' => 'bar'); print_r($bar); Array ( [foo] => bar )
Short Syntax für Arrays ab PHP 5.4:
$foo = ['foo', 'bar']; print_r($foo); Array ( [0] => foo [1] => bar ) $bar = ['foo' => 'bar']; print_r($bar); Array ( [foo] => bar )
PHP 5.4 ist aktuell im Alpha 2 Stadium und steht auf http://qa.php.net/ zum Download bereit.