Edit report at https://bugs.php.net/bug.php?id=60408&edit=1
ID: 60408 Comment by: bugzilla33 at gmail dot com Reported by: bugzilla33 at gmail dot com Summary: Array element access on instantiation (same like class member in 5.4RC) Status: Open Type: Feature/Change Request Package: Scripting Engine problem PHP Version: 5.4.0RC2 Block user comment: N Private report: N New Comment: >> echo array(1, 2, 3)[0]; //output 1 >> echo "foobar"[2]; //output o >> echo "foobar"["foo"][0] // output f >> works. Excellent! Have you tested it with short array constructor? echo [1, 2, 3][0]; //output 1 Are there any opportunities to make it public in the final PHP 5.4? Previous Comments: ------------------------------------------------------------------------ [2011-11-30 06:04:19] larue...@php.net see https://wiki.php.net/rfc/constdereference ------------------------------------------------------------------------ [2011-11-29 14:42:50] bugzilla33 at gmail dot com (edit summary) ------------------------------------------------------------------------ [2011-11-29 14:40:01] bugzilla33 at gmail dot com 20 Jun 2011, PHP 5.4.0 Alpha 1 -> Added array dereferencing support. (Felipe) 11 Nov 2011, PHP 5.4.0 RC1 -> Added class member access on instantiation (e.g. (new foo)->bar()) support. (Felipe) Many thanks for Felipe. It would be nice to add: Array element access on instantiation array()[$x] and [][$x] Then everything would be fully useful, but not in part. ------------------------------------------------------------------------ [2011-11-29 12:06:24] bugzilla33 at gmail dot com Description: ------------ Please add array constructor dereferencing support like JavaScript, C# and all languages excluding PHP 5.4 Test script: --------------- <?php $i=0; print(array('pa','th')[$i++]); // pa print(['wa','ss'][$i++]); // ss ?> Expected result: ---------------- Parse error: syntax error, unexpected '[' in C:\htdocs\test.pl\array.php on line 4 Actual result: -------------- pass ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60408&edit=1