Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67377 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12811 invoked from network); 9 May 2013 16:42:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 May 2013 16:42:46 -0000 Authentication-Results: pb1.pair.com header.from=theanomaly.is@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=theanomaly.is@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.179 as permitted sender) X-PHP-List-Original-Sender: theanomaly.is@gmail.com X-Host-Fingerprint: 209.85.215.179 mail-ea0-f179.google.com Received: from [209.85.215.179] ([209.85.215.179:58484] helo=mail-ea0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 73/32-30871-502DB815 for ; Thu, 09 May 2013 12:42:46 -0400 Received: by mail-ea0-f179.google.com with SMTP id h14so1660599eaj.38 for ; Thu, 09 May 2013 09:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=d68i78DVS0cyY6gP/J+3YsvbykCGAkWm3Sv67SQ73Bg=; b=lgA40vzmBXMfk2EEzogsRORecnl9N6r6EQCzJ/NXclz0kK8fnXeVSyFLNXfcYwXjnY gFVN4C4GhF7Cs9P+9yVQsDIWJctHsFhaebcrQY108WB056AUmFI9PT2VVt7cG/ZrOvGw 5oWaBp3RgE10bLbzIu7QAxPl5arKId4appR1Rcb5gX1bpmaNUaYULiZPhsg2smpXWdK2 9MgBjTDdMlVjTWBlrhSzQnf+tuiAb+UgfZuKR5QgbiKxJMT9HwxXHJTrS27YdwbB2cPY ofJRhd3kQqOQjHgl/gE4kUZVjkETM4UFaWmyq5X1J3UOOyKN1TWAG2u5xlvG06FpWKKH LhRg== MIME-Version: 1.0 X-Received: by 10.15.95.74 with SMTP id bc50mr30741048eeb.36.1368117763257; Thu, 09 May 2013 09:42:43 -0700 (PDT) Received: by 10.15.75.199 with HTTP; Thu, 9 May 2013 09:42:43 -0700 (PDT) In-Reply-To: <518BD127.608@php.net> References: <518BD127.608@php.net> Date: Thu, 9 May 2013 12:42:43 -0400 Message-ID: To: Stefan Neufeind Cc: PHP Internals Content-Type: multipart/alternative; boundary=089e0168164c4a5a1004dc4bbd06 Subject: Re: [PHP-DEV] list() inside a foreach() From: theanomaly.is@gmail.com (Sherif Ramadan) --089e0168164c4a5a1004dc4bbd06 Content-Type: text/plain; charset=ISO-8859-1 On Thu, May 9, 2013 at 12:39 PM, Stefan Neufeind 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 > > --089e0168164c4a5a1004dc4bbd06--