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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
25 - 15 = ?
Subscribe to this entry?

 
 [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 29 02:01:30 2024 UTC