Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70193 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50699 invoked from network); 18 Nov 2013 15:57:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Nov 2013 15:57:44 -0000 Authentication-Results: pb1.pair.com smtp.mail=scope@planetavent.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=scope@planetavent.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain planetavent.de from 89.107.189.172 cause and error) X-PHP-List-Original-Sender: scope@planetavent.de X-Host-Fingerprint: 89.107.189.172 mail.xa8.serverdomain.org Linux 2.6 Received: from [89.107.189.172] ([89.107.189.172:39642] helo=mail.xa8.serverdomain.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DD/71-41213-6F83A825 for ; Mon, 18 Nov 2013 10:57:44 -0500 Received: from mail-ea0-f171.google.com (mail-ea0-f171.google.com [209.85.215.171]) (Authenticated sender: xa8190p1) by mail.xa8.serverdomain.org (mail.xa8.serverdomain.org) with ESMTPSA id 9366C284A3C4A for ; Mon, 18 Nov 2013 16:57:38 +0100 (CET) Received: by mail-ea0-f171.google.com with SMTP id h10so2517938eak.2 for ; Mon, 18 Nov 2013 07:57:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=HoW06xHiK/xOEAG6q73IzqOUur9eWLoZzHLDmKsto2A=; b=QoGurYJBo/6YpIkfv98XmHvEgn+jjwXtSWpsI8tqBOil4Lrw68ckql8GPF8/xi5pqQ yjU9GQT5YXNFoKlfnq9JbZEudxiRnq3dWQXM/4stW0gFFgfGQEfOIjaBo5kZUX4W5Dh/ ATwqO1OCCKqAbvhnhvDKQTUR3A+A+Iznezh2RYCuFteaPiXlkLfZv9vrPPPA3zS9GH+Y 2guhbkMDXa1kMHb1ZggZ+U4yLrZuebzF6TWwvIB8JGm3UvWI4SVCJq/Jvo4VoCwfDBkQ qSrHqEC/JsRLRJ8SCTwZfW0Ofdfh3oTcL9VMLNDkdqQ8AH9VEIPTnAqFFuRUSK2Nmu6x VYUg== MIME-Version: 1.0 X-Received: by 10.15.108.73 with SMTP id cc49mr1347270eeb.93.1384790258131; Mon, 18 Nov 2013 07:57:38 -0800 (PST) Received: by 10.14.9.133 with HTTP; Mon, 18 Nov 2013 07:57:38 -0800 (PST) In-Reply-To: <528A26D2.6020609@gmail.com> References: <528A26D2.6020609@gmail.com> Date: Mon, 18 Nov 2013 16:57:38 +0100 Message-ID: To: Alexey Zakhlestin Cc: PHP internals Content-Type: multipart/alternative; boundary=089e0168190c6ce99704eb759bb8 Subject: Re: [PHP-DEV] foreach and current() From: scope@planetavent.de (Nicolai Scheer) --089e0168190c6ce99704eb759bb8 Content-Type: text/plain; charset=UTF-8 Hi! On Mon, Nov 18, 2013 at 3:40 PM, Alexey Zakhlestin wrote: > On 18.11.13, 18:14, Nicolai Scheer wrote: > > Hi all! > > > [using current() inside for loop does not work] > > > > Does anyone know what the reasoning behind this behavious is? > > current() implementation predates foreach and is totally separate. Main > difference is, that current()'s "pointer" is attached to the array, and > foreach's pointer is external. > > so you can not run several each()/current() loops on array at the same > time, but you can have any number of nested foreach's iterating over the > same array independently. > > They can't really be combined because of backwards compatibility > Ok, thanks for the clarification. Maybe inserting a hint about this into the documentation should be considered. Actually I would not use such code in the wild, it was more an educational question. :) Greetings Nico --089e0168190c6ce99704eb759bb8--