3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function MyArray() { return array('de'=>array('eins','zwei','drei')); } // based on feature request for PHP3, nine years ago, per https://bugs.php.net/bug.php?id=2341 // bug refiled from version 3 to version 4 // but Sterling Hughes felt the 'WTF' factor was too high to have it fixed // now should work in PHP5.5 $arr1DE=myArray()['de']; $arr2DE=array('de'=>array('eins','zwei','drei'))['de']; var_dump($arr1DE, $arr2DE);
Output for 5.5.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(3) { [0]=> string(4) "eins" [1]=> string(4) "zwei" [2]=> string(4) "drei" } array(3) { [0]=> string(4) "eins" [1]=> string(4) "zwei" [2]=> string(4) "drei" }
Output for 5.4.0 - 5.4.45
Parse error: syntax error, unexpected '[' in /in/Em6Yd on line 12
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/Em6Yd on line 11
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/Em6Yd on line 11
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/Em6Yd on line 11
Process exited with code 255.