#49804 [Bgs]: cannot use [...] after a function returning array

From: Date: Wed, 07 Oct 2009 19:48:24 +0000
Subject: #49804 [Bgs]: cannot use [...] after a function returning array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-143360@lists.php.net to get a copy of this message
ID: 49804 User updated by: valerio dot giuffrida88 at gmail dot com Reported By: valerio dot giuffrida88 at gmail dot com Status: Bogus Bug Type: Compile Failure Operating System: ubuntu PHP Version: 5.2SVN-2009-10-07 (snap) New Comment: why not? Other languanges like C/C++ or java allows that Previous Comments: ------------------------------------------------------------------------ [2009-10-07 17:22:43] derick@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php . ------------------------------------------------------------------------ [2009-10-07 17:11:50] valerio dot giuffrida88 at gmail dot com Description: ------------ If i want to get an element of an array directly returned by a function, using [], it will prints Parse error: syntax error, unexpected '[', expecting ',' or ';' in php shell code on line 1 Reproduce code: --------------- $a = array("a","b","c"); echo array_values($a)[0]; //it (doesnt) works with any function that retuns an array Expected result: ---------------- print to screen something like that: a Actual result: -------------- Parse error: syntax error, unexpected '[', expecting ',' or ';' in php shell code on line 1 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49804&edit=1

« previous php.bugs (#143360) next »