Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42376 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13778 invoked from network); 26 Dec 2008 09:06:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Dec 2008 09:06:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=drwoland@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=drwoland@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.21 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: drwoland@gmail.com X-Host-Fingerprint: 209.85.218.21 mail-bw0-f21.google.com Received: from [209.85.218.21] ([209.85.218.21:47334] helo=mail-bw0-f21.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 83/22-33750-58E94594 for ; Fri, 26 Dec 2008 04:06:14 -0500 Received: by bwz14 with SMTP id 14so9886304bwz.23 for ; Fri, 26 Dec 2008 01:06:10 -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:sender :to:subject:mime-version:content-type:x-google-sender-auth; bh=51fkCugrga3qJM9aThR1fW5NP3TTR1hMw+cZ+zN5edA=; b=vrto9K1qnW0zEJ4E1zawda7VnMHBIxoHVFFB1UPBtGx5XPPCh4NPH2xoAwCejxnWz2 iadL9VQIx7EfPLp4hQtrveJX7EtKMaOXtvxGcPErfSCwQm+quCOnqTHaF6Pf2HdlPx+x wo4oDTyDCn2ijmZ0ISUoAyCaGSGm7DJ8O9ylU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:mime-version:content-type :x-google-sender-auth; b=DL1oULc5Iz6/ZaKLZ0a/P6oBXnBKWhOvz04ZJQKs4uOJBA8KVTo2qHvW59clIZoSyE AoGHUyhfpssTaYCJyYTzNZfvKPQt1W9ulknEtjBEbDTTkAeQ/MmIoyWrNrUEZLsNgej3 U+ZhABZ0sXh7BoejDMgzX8bXEWMTXhmA3bKvU= Received: by 10.181.214.13 with SMTP id r13mr3892089bkq.202.1230282370568; Fri, 26 Dec 2008 01:06:10 -0800 (PST) Received: by 10.181.227.16 with HTTP; Fri, 26 Dec 2008 01:06:10 -0800 (PST) Message-ID: <5faa7b820812260106p6f24bf0ct49ef574e5ed4e2c2@mail.gmail.com> Date: Fri, 26 Dec 2008 01:06:10 -0800 Sender: drwoland@gmail.com To: internals@lists.php.net MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_119690_872692.1230282370565" X-Google-Sender-Auth: c2d31ec2e9a111bc Subject: Proposal: array_flatten function From: m@mihasya.com ("Mike Panchenko") ------=_Part_119690_872692.1230282370565 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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. 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. Ooops, not that short I guess... Cheers. Mike. ------=_Part_119690_872692.1230282370565--