Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79776 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89542 invoked from network); 17 Dec 2014 13:07:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Dec 2014 13:07:54 -0000 Authentication-Results: pb1.pair.com header.from=cmbecker69@gmx.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=cmbecker69@gmx.de; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.de designates 212.227.15.15 as permitted sender) X-PHP-List-Original-Sender: cmbecker69@gmx.de X-Host-Fingerprint: 212.227.15.15 mout.gmx.net Received: from [212.227.15.15] ([212.227.15.15:64681] helo=mout.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 03/00-23459-82081945 for ; Wed, 17 Dec 2014 08:07:53 -0500 Received: from [192.168.0.101] ([91.67.244.80]) by mail.gmx.com (mrgmx003) with ESMTPSA (Nemesis) id 0MRXSK-1YTwMZ2xMu-00SiYX; Wed, 17 Dec 2014 14:07:43 +0100 Message-ID: <54918022.9000302@gmx.de> Date: Wed, 17 Dec 2014 14:07:46 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: "guilhermeblanco@gmail.com" , Derick Rethans CC: Stanislav Malyshev , PHP Internals References: <548FEE87.7020602@gmail.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:TnzTvVUVL4X8tnkFREo/nt/cabKc0f/dlq8E+V0Jo4MC2bCbWh/ uaVBCnMnnibCoL4BQgMEAl6+htDf5IEZH8dRKNmzzC7uqinPIwSyKeLUjtPfxbd0STIiGS0 WXzujb6Y38KM9SCvF/1w2s6aWhQXu+frmXHTR4kG3cU0ALPtrgUS43TaC2bkfb6QM9ytLd0 fzlzR/Z6ZpCNvGEtK/+Mw== X-UI-Out-Filterresults: notjunk:1; Subject: Re: [PHP-DEV] [RFC][VOTE] Objects as Keys From: cmbecker69@gmx.de (Christoph Becker) guilhermeblanco@gmail.com wrote: > Answering the question of Christopher Becker. It is not possible to > traverse and get your desired elements. > How would you achieve a foreach by key (returning object) without having to > store a separate list and track by hash or through an interface? AIUI, the RFC proposes that __hash() returns a string or an int, and this value (not the object itself) will be stored and retrieved as key of the array. : | Create a new magic method, __hash() which is called when object is | supplied as a hash key, and returns string or integer that is used as | the hash key. -- Christoph M. Becker