|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-11-05 09:26 UTC] bugs dot php dot net at dzubak dot sk
-Summary: reset() & end() to return value for "not variables"
like empty() in PHP 5.5
+Summary: reset() & end() could return value of arbitrary
expression
[2014-11-05 09:26 UTC] bugs dot php dot net at dzubak dot sk
[2014-11-06 08:12 UTC] bugs dot php dot net at dzubak dot sk
[2020-12-08 13:13 UTC] cmb@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: cmb
[2020-12-08 13:13 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 13 09:00:01 2025 UTC |
Description: ------------ Since PHP 5.5 empty() supports arbitrary expressions, could PHP do same with reset() and end()? I can simply add [0] to end of variable or function to get value of last element. However this approach does not work when I use arbitrary or non-integer keys. It is even more tricky when I want "just get last value" of array. Expected result: ---------------- I would welcome to be able to get first and last value of "any kind of array" like this: reset(someFunction()); # returns value of first element end(explode('/', '/very/long/path/to/filename.txt')); # returns filename without path (value of last element of explode()) Actual result: -------------- end([]); # Fatal error: Only variables can be passed by reference