z-loga
Last Updated: February 25, 2016
·
869
· zonetti
F46c21deea19955ae03c8f28aa6b9f99

PHP: Short syntax for arrays

Just letting you guys know that now you can do this:

$newSyntax = [
  'key' => 'value',
  'anotherKey' => 'anotherValue'
];

Instead of this:

$oldSyntax = array(
  'key' => 'value',
  'anotherKey' => 'anotherValue'
);

All you need is PHP 5.4 or higher.

For more info: https://wiki.php.net/rfc/shortsyntaxforarrays

Say Thanks
Respond

2 Responses
Add your response

4691
Frank avatar

I think in this example is missing a '

$newSyntax = [
  'key' => 'value',
  'anotherKey' => 'anotherValue'
];
over 1 year ago ·
4692
F46c21deea19955ae03c8f28aa6b9f99

@bueltge True. Fixed. Thanks :D

over 1 year ago ·