Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80867 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93884 invoked from network); 20 Jan 2015 09:27:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jan 2015 09:27:29 -0000 Authentication-Results: pb1.pair.com header.from=me@kelunik.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=me@kelunik.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kelunik.com from 81.169.146.218 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 81.169.146.218 mo4-p00-ob.smtp.rzone.de Received: from [81.169.146.218] ([81.169.146.218:18229] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7D/52-15586-E7F1EB45 for ; Tue, 20 Jan 2015 04:27:28 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1421746044; l=1482; s=domk; d=kelunik.com; h=Content-Transfer-Encoding:Content-Type:Cc:To:From:Subject:Date: References:In-Reply-To:MIME-Version; bh=kbvDzbkQVnmPhB2S69LiUIAMhrg=; b=hXTX/G6rrX4uqWeC5/da1YQN7TagaIBmR9BxzEs7upeRHmWzRayH/khMsv8Xsk1n8ow 56CyJnkISeZ3lfwhz4HkwR/ChvsdA9wK1vcmrVaAjAinyhTEAf44o9WBpTUFtMRsThkOu n6cEcXK+GK7TAiK52kcHfD+qry4tON4mBnU= X-RZG-AUTH: :IWkkfkWkbvHsXQGmRYmUo9mls2vWuiu+7SLGvomb4bl9EfHtPntW9w== X-RZG-CLASS-ID: mo00 Received: from mail-we0-f181.google.com ([74.125.82.181]) by smtp.strato.de (RZmta 36.3 AUTH) with ESMTPSA id 605cber0K9RNLnF (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) for ; Tue, 20 Jan 2015 10:27:23 +0100 (CET) Received: by mail-we0-f181.google.com with SMTP id q58so35919459wes.12 for ; Tue, 20 Jan 2015 01:27:23 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.194.179.166 with SMTP id dh6mr18544089wjc.87.1421746043834; Tue, 20 Jan 2015 01:27:23 -0800 (PST) Received: by 10.27.200.193 with HTTP; Tue, 20 Jan 2015 01:27:23 -0800 (PST) In-Reply-To: References: Date: Tue, 20 Jan 2015 10:27:23 +0100 Message-ID: To: Pierre Joye Cc: Andrea Faulds , Mike Willbanks , PHP Internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] in Operator From: me@kelunik.com (Niklas Keller) 2015-01-20 6:35 GMT+01:00 Pierre Joye : > On Tue, Jan 20, 2015 at 6:15 AM, Andrea Faulds wrote: >> Hi Mike, >> >>> On 20 Jan 2015, at 03:30, Mike Willbanks wrote: >>> >>> I am very familiar with the in operator. However, the implementation >>> would be incomplete without handling loops via the in operator. Many >>> people when seeing an in operator also think of JavaScript. In that ca= se >>> the in operator iterates over properties. As such in PHP we should be = able >>> to iterate over associative arrays should the syntax be added. >>> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/State= ments/for...in >> >> Why? We already have foreach/as which does exactly that, and unlike JS w= hich added for/of, there=E2=80=99s nothing wrong with PHP=E2=80=99s foreach= so we don=E2=80=99t need support for a new symbol. > > Indeed, exactly same feature. > > Otherwise, well done again Andrea, love it ::) > > -- > Pierre > > @pierrejoye | http://www.libgd.org Hi Mike and Andrea, > In that case the in operator iterates over properties. As such in PHP we= should be able to iterate over associative arrays should the syntax be add= ed. The reason why I didn't include this the reason Andrea mentioned: We already have `foreach`. > My assumption would be visible properties from the context which you are = in. Yes, this is what I'd suggest. Regards, Nick