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.

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

Reply via email to