php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49804 cannot use [...] after a function returning array
Submitted: 2009-10-07 17:11 UTC Modified: 2009-10-07 19:48 UTC
From: valerio dot giuffrida88 at gmail dot com Assigned:
Status: Not a bug Package: Compile Failure
PHP Version: 5.2SVN-2009-10-07 (snap) OS: ubuntu
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: valerio dot giuffrida88 at gmail dot com
New email:
PHP Version: OS:

 

 [2009-10-07 17:11 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-07 17:22 UTC] 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 19:48 UTC] valerio dot giuffrida88 at gmail dot com
why not?
Other languanges like C/C++ or java allows that
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 10:01:33 2025 UTC