Req #68341 [Opn]: reset() & end() could return value of arbitrary expression

From: Date: Thu, 06 Nov 2014 08:12:53 +0000
Subject: Req #68341 [Opn]: reset() & end() could return value of arbitrary expression
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188483@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68341&edit=1 ID: 68341 User updated by: bugs dot php dot net at dzubak dot sk Reported by: bugs dot php dot net at dzubak dot sk Summary: reset() & end() could return value of arbitrary expression Status: Open Type: Feature/Change Request Package: Arrays related PHP Version: 5.5.18 Block user comment: N Private report: N New Comment: I made mistake in this sentence: I can simply add [0] to end of variable or function to get value of **FIRST** element. Previous Comments: ------------------------------------------------------------------------ [2014-11-05 09:26:05] bugs dot php dot net at dzubak dot sk updated summary, hopefully it will make more sense ------------------------------------------------------------------------ [2014-11-04 10:22:59] bugs dot php dot net at dzubak dot sk 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=68341&edit=1

« previous php.bugs (#188483) next »