Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70191 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44955 invoked from network); 18 Nov 2013 14:14:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Nov 2013 14:14:25 -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:49355] helo=mail.xa8.serverdomain.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 40/A0-41213-FB02A825 for ; Mon, 18 Nov 2013 09:14:24 -0500 Received: from mail-ee0-f51.google.com (mail-ee0-f51.google.com [74.125.83.51]) (Authenticated sender: xa8190p1) by mail.xa8.serverdomain.org (mail.xa8.serverdomain.org) with ESMTPSA id DEA0528383772 for ; Mon, 18 Nov 2013 15:14:20 +0100 (CET) Received: by mail-ee0-f51.google.com with SMTP id d41so1828073eek.24 for ; Mon, 18 Nov 2013 06:14:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:date:message-id:subject:from:to:content-type; bh=NXZHqdQSPs8klR0pkcWGsz75WuO1qxKA0YfiRCAFm/I=; b=BZDNSteQ8PM+EGnal/VwFngn78fAYEDmn651KvVfn2j9eYbSJY07B6QjO8nfcHPnja 3K9frEOxVbCugFhyBpqbB/4P9gpi7IgiSBmHqat9QgGZj96mRpxDUKpqOzhCR1dhISP+ tsfOM777NBEAzboQOZEfjKIswf+mDk3PtLvqd5XsdLCHtKwqKp+XHBHX8dXgY5/EE9vB nv2NTTj2ktoCgneen9k1j2iDKWn7L4EYglBnUgWaR7tLJJT6ShgZCHNXFGDVNIptE6CR 5SA6MlZKfb7ycdHvKoz2R+RcEaWFsbJcRoP8dY1Y4Nb070OZ4L3fbAa6c49Ih9pxOevi Vsfw== MIME-Version: 1.0 X-Received: by 10.15.94.70 with SMTP id ba46mr358941eeb.22.1384784060794; Mon, 18 Nov 2013 06:14:20 -0800 (PST) Received: by 10.14.9.133 with HTTP; Mon, 18 Nov 2013 06:14:20 -0800 (PST) Date: Mon, 18 Nov 2013 15:14:20 +0100 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary=089e01681fee08cd5504eb742a7d Subject: foreach and current() From: scope@planetavent.de (Nicolai Scheer) --089e01681fee08cd5504eb742a7d Content-Type: text/plain; charset=UTF-8 Hi all! Has it been always the way, that it is not possible to use current() in a foreach loop? Just stumbled upon (using php 5.5.5): $arr = array( "a", "b", "c" ); foreach( $arr as $entry ) { #var_dump( current($arr) ); } var_dump( current($arr) ); Which yields "false", because the internal array pointer points behind the last element of $arr. If I uncomment the inner var_dump(), the script outputs "b" four times. This seems odd... I know that the documentation advises not to fiddle with the internal array pointer in a foreach loop, but current() should not affect it in any way and therefor should be safe to use. Does anyone know what the reasoning behind this behavious is? Greetings Nico --089e01681fee08cd5504eb742a7d--