#50004 [Csd]: Allow constructions like func()[0]

From: Date: Mon, 26 Oct 2009 18:52:45 +0000
Subject: #50004 [Csd]: Allow constructions like func()[0]
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-143973@lists.php.net to get a copy of this message
ID: 50004 User updated by: melfar at gmail dot com Reported By: melfar at gmail dot com Status: Closed Bug Type: Feature/Change Request Operating System: agnostic PHP Version: 5.3.0 New Comment: Closing Previous Comments: ------------------------------------------------------------------------ [2009-10-26 18:52:07] melfar at gmail dot com Duplicate of bug 50003 ------------------------------------------------------------------------ [2009-10-26 18:45:42] melfar at gmail dot com Description: ------------ PHP parser doesn't allow for array index operation to be used on a result of a function call. I propose a patch to allow such a construction. Reproduce code: --------------- <?php function car_brands() { return array("chevy", "hummer"); } print car_brands()[1] . "\n"; ?> Expected result: ---------------- "hummer" Actual result: -------------- Parse error: syntax error, unexpected '[' in test.php on line 5 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50004&edit=1

« previous php.bugs (#143973) next »