#42440 [Opn->Bgs]: Unable to access to a member of an array returned by a function

From: Date: Mon, 27 Aug 2007 10:22:54 +0000
Subject: #42440 [Opn->Bgs]: Unable to access to a member of an array returned by a function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-116711@lists.php.net to get a copy of this message
ID: 42440 Updated by: jani@php.net Reported By: romain dot tartiere at healthgrid dot org -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: GNU/Linux PHP Version: 5.2.3 New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [2007-08-27 10:00:01] romain dot tartiere at healthgrid dot org Description: ------------ When using a function that returns an array, the parser is not apple to correctly parse the expression and assign the n'th element to a variable Reproduce code: --------------- <?php function foo() { return array(1, 2, 3); } echo foo()[1]; # <<< ?> Expected result: ---------------- 2 (second element of the array) Actual result: -------------- Parse error: syntax error, unexpected '[', expecting ',' or ';' ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42440&edit=1

« previous php.bugs (#116711) next »