1
0
mirror of https://github.com/php/php-src.git synced 2026-04-26 17:38:14 +02:00

- add short array syntax as defined in https://wiki.php.net/rfc/shortsyntaxforarrays, 2nd solution using => only

This commit is contained in:
Pierre Joye
2011-07-23 20:23:21 +00:00
parent 35f58b972f
commit cbe0ed86e7
6 changed files with 66 additions and 1 deletions
+13
View File
@@ -0,0 +1,13 @@
--TEST--
Square bracket array shortcut test
--FILE--
<?php
print_r([1, 2, 3]);
?>
--EXPECT--
Array
(
[0] => 1
[1] => 2
[2] => 3
)
+13
View File
@@ -0,0 +1,13 @@
--TEST--
Square bracket associative array shortcut test
--FILE--
<?php
print_r(["foo" => "orange", "bar" => "apple", "baz" => "lemon"]);
?>
--EXPECT--
Array
(
[foo] => orange
[bar] => apple
[baz] => lemon
)
+13
View File
@@ -0,0 +1,13 @@
--TEST--
Testing array shortcut and bracket operator
--FILE--
<?php
$a = [1, 2, 3, 4, 5];
print_r([$a[1], $a[3]]);
?>
--EXPECT--
Array
(
[0] => 2
[1] => 4
)
+20
View File
@@ -0,0 +1,20 @@
--TEST--
Testing nested array shortcut
--FILE--
<?php
print_r([1, 2, 3, ["foo" => "orange", "bar" => "apple", "baz" => "lemon"]]);
?>
--EXPECT--
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => Array
(
[foo] => orange
[bar] => apple
[baz] => lemon
)
)