Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38316 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82493 invoked from network); 17 Jun 2008 09:21:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jun 2008 09:21:09 -0000 Authentication-Results: pb1.pair.com header.from=et@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=et@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 62.75.137.136 as permitted sender) X-PHP-List-Original-Sender: et@php.net X-Host-Fingerprint: 62.75.137.136 fuer-et.de Linux 2.5 (sometimes 2.4) (4) Received: from [62.75.137.136] ([62.75.137.136:52390] helo=eve.fuer-et.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D2/73-61252-30287584 for ; Tue, 17 Jun 2008 05:21:08 -0400 Received: from lapalma.mis.informatik.tu-darmstadt.de (lapalma.mis.informatik.tu-darmstadt.de [130.83.165.195]) by eve.fuer-et.de (Postfix) with ESMTP id C4BB615E7AE; Tue, 17 Jun 2008 11:21:04 +0200 (CEST) To: internals@lists.php.net Date: Tue, 17 Jun 2008 11:21:03 +0200 User-Agent: KMail/1.9.7 Cc: "Arvids Godjuks" , "Edward Z. Yang" References: <77972256-ED0C-4FCE-8DEF-8283FE1BBFC5@roshambo.org> <28.6B.06776.09A76584@pb1.pair.com> <9b3df6a50806162327r52ae3ad9g65d56c0916571185@mail.gmail.com> In-Reply-To: <9b3df6a50806162327r52ae3ad9g65d56c0916571185@mail.gmail.com> X-PGP-Key-URL: http://www.mis.informatik.tu-darmstadt.de/People/walk/ MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200806171121.03786.et@php.net> Subject: Re: [PHP-DEV] deprecation status of $str{42} versus $str[42] From: et@php.net (Stefan Walk) On Tuesday 17 June 2008 08:27:37 Arvids Godjuks wrote: > 2008/6/16 Edward Z. Yang : > > PHP userland code may not treat strings as first class arrays, but > > that's certainly how they are represented internally. > > > > Anyway, it would be neat if we could get that foreach syntax to work. I > > get sick of for($i = 0, $c = strlen($str); $i < $c; $i++) very quickly. > > Totaly agree, the best example from the whole thread You're not learning from the mistakes of other languages (ruby in this case, which removed Enumerable from String in 1.9) ... "foreach" makes no sense for strings, because it's unclear what you want (with unicode terminology here, as this is for php6): "for each byte" "for each codeunit" "for each codepoint", or "for each line", or ... if you want to use foreach in your example, just do foreach (str_split($str) as $value) { ... Regards, Stefan