Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67376 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11374 invoked from network); 9 May 2013 16:39:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 May 2013 16:39:10 -0000 Authentication-Results: pb1.pair.com header.from=neufeind@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=neufeind@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 91.184.32.3 as permitted sender) X-PHP-List-Original-Sender: neufeind@php.net X-Host-Fingerprint: 91.184.32.3 mail.speedpartner.de Received: from [91.184.32.3] ([91.184.32.3:55038] helo=mail.speedpartner.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DF/D1-30871-C21DB815 for ; Thu, 09 May 2013 12:39:10 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.speedpartner.de (Postfix) with ESMTP id C6471620B2 for ; Thu, 9 May 2013 18:39:03 +0200 (CEST) Received: from mail.speedpartner.de ([127.0.0.1]) by localhost (mail.speedpartner.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0bElXbjEfd1e for ; Thu, 9 May 2013 18:39:03 +0200 (CEST) Received: from collab.speedpartner.de (collab.speedpartner.de [91.184.32.10]) by mail.speedpartner.de (Postfix) with ESMTP id B11E5620A5 for ; Thu, 9 May 2013 18:39:03 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by collab.speedpartner.de (Postfix) with ESMTP id D90A8CEE6E8 for ; Thu, 9 May 2013 18:39:00 +0200 (CEST) X-Virus-Scanned: amavisd-new at collab.speedpartner.de Received: from collab.speedpartner.de ([127.0.0.1]) by localhost (collab.speedpartner.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LutrItMJjnmz for ; Thu, 9 May 2013 18:38:59 +0200 (CEST) Received: from [192.168.4.28] (ip-176-199-169-125.unitymediagroup.de [176.199.169.125]) by collab.speedpartner.de (Postfix) with ESMTPSA id 56981CE432B for ; Thu, 9 May 2013 18:38:59 +0200 (CEST) Message-ID: <518BD127.608@php.net> Date: Thu, 09 May 2013 18:39:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: list() inside a foreach() From: neufeind@php.net (Stefan Neufeind) 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