Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42132 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94136 invoked from network); 7 Dec 2008 01:35:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Dec 2008 01:35:42 -0000 Authentication-Results: pb1.pair.com header.from=igor.feghali@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=igor.feghali@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 64.233.170.190 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: igor.feghali@gmail.com X-Host-Fingerprint: 64.233.170.190 rn-out-0910.google.com Received: from [64.233.170.190] ([64.233.170.190:7907] helo=rn-out-0910.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 21/70-22537-D682B394 for ; Sat, 06 Dec 2008 20:35:42 -0500 Received: by rn-out-0910.google.com with SMTP id k40so565821rnd.0 for ; Sat, 06 Dec 2008 17:35:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=qfPMnB60y8me8uYEADOJUod3BeEbQaK4mVW+vR4sCgs=; b=WQiKMicONrPtlw2l5C+XBlRv5Wv3IlD1CeTqzwmUVccQnJJmsN8dqK6AKX7pZKTnyO tNcNahYKgNAzNqf+w3OKvivcVAuEGHa+p2uowR73FL+Dl40sWKPKtZfWAgtqmljauIh4 u07WUuLplPizA1kw6T/3rgieuzAckV7pFYLlk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=br1HuxIoMUVtHrVS/RX7yyvPjKNToZkpnsEIZwOAGS8reEv1VVmSeg5PGBXwtMOX2X tGqbYY9RSfn+zbZvHN3EEEoF0JsaHt2WqE+j9Ez5vF1K5B5RCp2aqgoL3uocciAtD7yg 8hAH/tYO2sjse8SFkyeYnHDGbiQ3ubo+9XLec= Received: by 10.150.201.2 with SMTP id y2mr4905547ybf.26.1228613738061; Sat, 06 Dec 2008 17:35:38 -0800 (PST) Received: by 10.150.157.16 with HTTP; Sat, 6 Dec 2008 17:35:38 -0800 (PST) Message-ID: Date: Sat, 6 Dec 2008 23:35:38 -0200 To: "Lars Strojny" Cc: "PHP Internals List" In-Reply-To: <1228611165.18444.7.camel@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1228604866.18444.3.camel@localhost> <1228611165.18444.7.camel@localhost> Subject: Re: [PHP-DEV] Implode() FR and Patch From: igor.feghali@gmail.com ("Igor Feghali") On Sat, Dec 6, 2008 at 22:52, Lars Strojny wrote: > Alright, than I would appreciate a few real world use cases. Ok one immediate use case I can think of: http://pear.php.net/package/Numbers_Words In brazilian portuguese we write numbers like that: 1023 => mil e vinte e tres 123 => cento e vinte e tres 23 => vinte e tres 20 => vinte So we can have an array that binds '3' to 'tres', '2' as a dozen to 'vinte', zero to false or empty string, etc. Parse the numbers from left to right adding each word as an array element. In the end we can just implode everything using the delimiter ' e '. Using actual implode for the number 1023 would result as 'mil e e vinte e tres' instead of just 'mil e vinte e tres'. Using array_filter before every implode() would add a big visual overhead. I don't want to get into deeper details but translating numbers to pt_br words is a lot more complex. We actually have to parse, evaluate and implode() every "chunk" of three numbers first, then add all the chunks to a new array and finally implode() everything together because there are different rules for inter-chunks "relationship" and intra-chunks relationship. I am not saying the use of array_filter *is* a bottleneck. But I am sure there are a *lot* of heavy applications out there that runs a lot happier with any bit of performance gain. Also less code means happier programmers. Example: function myfunc($var) { // logic to test if var is not null, not false, not empty string etc. } // NOTE: leaving the callback function empty is not desired. 0 and 0.0 should not be skipped in the implode array ! array_filter($arr, 'myfunc'); implode('foo', $arr); against: implode('foo', $arr, true); Again this is just one single example. I had to deal with this situation a *lot* of times before. > I guess you meant "Absolutely not" ;-) Absolutely (now I think its used correctly...) > The procedure: register a wiki account and start using the "template" > from the traits proposal. We are pretty liberal with adding/removing > chapters, so adjust it as much as you need it to make your point clear. Right. Best Regards, Igor Feghali.