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:
@@ -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
|
||||
)
|
||||
@@ -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
|
||||
)
|
||||
@@ -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
|
||||
)
|
||||
@@ -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
|
||||
)
|
||||
|
||||
)
|
||||
Reference in New Issue
Block a user