Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53398 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52979 invoked from network); 20 Jun 2011 12:21:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jun 2011 12:21:20 -0000 Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 209.85.220.170 mail-vx0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:35817] helo=mail-vx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 79/DD-34681-F3B3FFD4 for ; Mon, 20 Jun 2011 08:21:20 -0400 Received: by vxi39 with SMTP id 39so870341vxi.29 for ; Mon, 20 Jun 2011 05:21:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=e+C0JHL+vzCuJKb93oNco9ifEGD+HI8rFrNdYuwrV50=; b=vNFdYglpE6j2MpRwgDryaqIcJ8biH6kTq2TGhOv0tzDnvYtbiSqTngDwLmMfU5PVY7 4a3HdVVovQCGjezv0TNRI1E8eA4I/OVWbVTXHSu3kqqhN2R3I1TxS/scVv8aCTAFwfq4 aW250zwbpq4EKMio8jqVP2gbuRpHbdMMJjXd4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=tEfAWIsQNYLfY8uRCkGqlEaACQbEacZq4/AO7RQz2f4g41t08/7tiX30HHzufwVLF4 dG7/2AVTl4dfbJoleWgoAlTZEueqgy6UTvvxXStLTyp0RIrG7Z42RGvHa3J45c/5YJ2N EGpvA2xerMpZIY0da0ZbUwmDLX/2ZVGv+7RpY= MIME-Version: 1.0 Received: by 10.52.113.169 with SMTP id iz9mr24969vdb.224.1308572168954; Mon, 20 Jun 2011 05:16:08 -0700 (PDT) Received: by 10.52.160.33 with HTTP; Mon, 20 Jun 2011 05:16:08 -0700 (PDT) In-Reply-To: References: Date: Mon, 20 Jun 2011 14:16:08 +0200 Message-ID: To: Robert Eisele Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] foreach() for strings From: pierre.php@gmail.com (Pierre Joye) hi Robert, I would go with a RFC for that one, at least to document/cover edge cases to help the doc team to properly document this change if it gets approved. Thanks for your work so far! On Mon, Jun 20, 2011 at 1:27 PM, Robert Eisele wrote: > foreach() has many functions, looping over arrays, objects and implementing > the iterator interface. I think it's also quite intuitive to use foreach() > for strings, too. > > If you want to implement a parser in PHP, you have to go the way with for + > strlen + substr() or $x[$i] to address one character of the string. We could > overdo the functionality of foreach() > by implementing LVAL's, too, in order to access single bits but this is > really uncommon, even if the way of thinking could be, that foreach() gives > a single attribute of each value, no matter > if it's a complex object with the iterator interface or a primitive. What do > you think about this one? My point of view is, that foreach() is very > useful, which was acknowledged by many ppl via the comments of my article. > > I think, adding features like this persuades the one or the other PHP user > to upgrade to 5.4. > > Robert > -- Pierre @pierrejoye | http://blog.thepimp.net | http://www.libgd.org