Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shorthand syntax for PHP arrays

Tags:

syntax

php

Is this valid PHP syntax or just a shorthand for the documentation? Does anybody have the link to a help page describing this notation?

$array = [
  [1, 2],
  [3, 4],
];

If you have a look at the code examples in the Unpacking nested arrays with list() section on the foreach help page you will see this possibly new notation, however I can't seem to find any help for this.

like image 854
Precastic Avatar asked Jun 26 '26 07:06

Precastic


1 Answers

The new syntax [] was added in PHP 5.4.0. Check out the documentation on arrays

like image 183
galymzhan Avatar answered Jun 28 '26 01:06

galymzhan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!