From:             php at xyzzy dot cjb dot net
Operating system: Mac OS X 10.5.2
PHP version:      5.2.5
PHP Bug Type:     Feature/Change Request
Bug description:  Syntax to index within an expression that evaluates to an 
array

Description:
------------
It would be nice if PHP could allow you to use the [] operator to index 
within an expression that evaluates to an array, as if it was a 
variable.

This feature request is similar to #41268 "Access array member without 
variable", but suggests using the existing [] operator rather than 
adding a new function. I could not find further details on php-internals 
about this issue.

Reproduce code:
---------------
For example:

  $lines = split("\n", $text)
  print $lines[0]

cannot currently be written as

   print split("\n", $text)[0]

nor

   print (split("\n", $text))[0]

Expected result:
----------------
The second and third examples behave identically to the first.

Actual result:
--------------
Parse error: syntax error, unexpected '[' in - on line 2

-- 
Edit bug report at http://bugs.php.net/?id=44368&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=44368&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=44368&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=44368&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=44368&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=44368&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=44368&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=44368&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=44368&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=44368&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=44368&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=44368&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=44368&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=44368&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=44368&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=44368&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=44368&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=44368&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=44368&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=44368&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=44368&r=mysqlcfg

Reply via email to