Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42377 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15843 invoked from network); 26 Dec 2008 09:23:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Dec 2008 09:23:55 -0000 Authentication-Results: pb1.pair.com smtp.mail=indeyets@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=indeyets@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.44.29 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: indeyets@gmail.com X-Host-Fingerprint: 74.125.44.29 yx-out-2324.google.com Received: from [74.125.44.29] ([74.125.44.29:44322] helo=yx-out-2324.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AB/82-33750-AA2A4594 for ; Fri, 26 Dec 2008 04:23:54 -0500 Received: by yx-out-2324.google.com with SMTP id 3so1996142yxj.83 for ; Fri, 26 Dec 2008 01:23:51 -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=2uzscKz5qdDYIJ6Rfi1/N8zh6yQrOEmoEtkvcuH5dp0=; b=c+OrWBHfbuQyWTLgA/wUEA16P9ZLt9JdxeXblmzzBQFl7hp9r7BX4dLe9q4ugXyU0E obCNWOv0sqrA7exmvK7yKjaTXdI4OM3/xfLOZ59RGcIboVxozU0YApjgMdOgqKxz7ADW rtgp/tRke/c8BpCwpBkHEU1Av86WuGjSI7/Pg= 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=NsKnxdmnbHt3DeMqzbFzABQvhQUOOxayDzrRnSc5oPDUrzyj9rc5ejNaUGsORngoQr hFHI4zSmi/vXW6ghEM1P3bsXEW9sHKMA5eXTtu0c58cr5UtzbY/iW0690LeB4k9q40Eo 6gAWnHj8mxeLQVix/nzRpx3HZJNuRciDOx5OE= Received: by 10.100.122.12 with SMTP id u12mr6194828anc.78.1230283431477; Fri, 26 Dec 2008 01:23:51 -0800 (PST) Received: by 10.100.32.2 with HTTP; Fri, 26 Dec 2008 01:23:51 -0800 (PST) Message-ID: Date: Fri, 26 Dec 2008 12:23:51 +0300 To: "Mike Panchenko" Cc: internals@lists.php.net In-Reply-To: <5faa7b820812260106p6f24bf0ct49ef574e5ed4e2c2@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <5faa7b820812260106p6f24bf0ct49ef574e5ed4e2c2@mail.gmail.com> Subject: Re: [PHP-DEV] Proposal: array_flatten function From: indeyets@gmail.com ("Alexey Zakhlestin") On Fri, Dec 26, 2008 at 12:06 PM, Mike Panchenko wrote: > Hey everybody, I'm new both to the list and to hacking the internals, so > I'll try to keep it short and humble. > > I've written an array_flatten function which just takes all elements from a > nested array and pushes them into a single indexed array. > > Couple of questions: > > 1. Most importantly, is this patch-worthy to everybody? I was a bit > surprised that it didn't already exist (it wasn't difficult to write, even > for me :) ), and a search turns up quite a few posts both on the PHP doc > comments and elsewhere detailing how to do the same in usersland PHP. There > are some pretty clear usecases for this, such as doing statistics on a > grouped dataset, as well as grabbing all values from a single-column SQL > query. It's a very simple, unobtrusive patch. regarding SQL: PDO has nice $stmt->fetchAll(PDO::FETCH_COLUMN) mode which does exactly this :) > 2. One of the PHP implementations "preserved keys." This seems > counterintuitive to me, as there's a high probability of overwriting, and I > can't think of a usecase where one would want to flatten out an array, but > keep the keys. Nonetheless, it was implemented by one of the snippets I saw. > Should the function offer this option with a $preserveKeys = false optional > param? If so, how should I handle duplicate keys? Failure? Warning? IMO, > it's not worthwhile, but I wanted to get opinions. > > 3. (this is where the noob comes in) What is the protocol on creating > patches? Should I just run the CVS patch command against a major revision? I > haven't used that before, but it seems straight forward enough. If someone > can point me to a writeup of the exact "correct" way to generate a patch, > I'd appreciate it. "cvs diff -u" against 5.3 branch shoould be ok for the start. after positive review, "cvs diff -u" against HEAD would be needed to -- Alexey Zakhlestin http://www.milkfarmsoft.com/