php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #50004 Allow constructions like func()[0]
Submitted: 2009-10-26 18:45 UTC Modified: 2009-10-26 18:52 UTC
From: melfar at gmail dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 5.3.0 OS: agnostic
Private report: No CVE-ID: None
 [2009-10-26 18:45 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-26 18:52 UTC] melfar at gmail dot com
Duplicate of bug 50003
 [2009-10-26 18:52 UTC] melfar at gmail dot com
Closing
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 01 05:01:29 2024 UTC