On Thu, May 9, 2013 at 12:39 PM, Stefan Neufeind <neufe...@php.net> wrote:
> Hi, > > trying out the following source I was astonished to see that using > list() does not work directly in a foreach() but works fine if used > through a temporary variable. > > Hi, This feature was already voted in and accepted. https://wiki.php.net/rfc/foreachlist#vote It has been implemented in PHP 5.5 > Would allowing using list() inside the foreach()-statement be desired > behaviour? Or is it just me? :-) > > > $a = array( > array(5, 'A'), > array(3, 'B'), > ); > foreach($a as list($k, $v)) { > echo $k; > } > > Expected output: 53 > > Result: syntax error, unexpected 'list' (T_LIST) in ... > > > Works: > foreach($a as $b) { > list($k, $v) = $b; > echo $k; > } > > > Kind regards, > Stefan > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >