Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93629 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34589 invoked from network); 29 May 2016 22:19:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 May 2016 22:19:18 -0000 Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.53 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 74.125.82.53 mail-wm0-f53.google.com Received: from [74.125.82.53] ([74.125.82.53:37404] helo=mail-wm0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3E/40-29541-3EA6B475 for ; Sun, 29 May 2016 18:19:16 -0400 Received: by mail-wm0-f53.google.com with SMTP id z87so51201847wmh.0 for ; Sun, 29 May 2016 15:19:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=qgAkNVtWcKj+Co64vBVTj0zPuSS6QfB8E8+/h/PFaSk=; b=gjRKm0bWqiLQi3amF6y94u7IkMONjTJ0rr6kAbY/Rs/hozAYb79e2POCwiImMLs4uW WyPRZJP8SIQ3GZrQqom29gcL40ddxxj/bJAuue2EcdRxSK1jBV+JZ7yW6tnYyB4ajcgA Sxni1uTB7wFE7EV1k2Evm44Ghsbjgh2mkASic+A2NCM9SR+WlA3laMm5FQecngxX4c3T PoO/snisg7odNxjIQB5Rc6ncCddSsVV+llAsrr7lrEBulDVO7g0UvHYu2Es3BCBIc7xC /6Kt7ZFn4Ca9Z1DWr47sdxdCo0eOxg4Rd4rGV9RIr8Pbl9jVsD5Xsntkq9wncvwDCILN kX/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=qgAkNVtWcKj+Co64vBVTj0zPuSS6QfB8E8+/h/PFaSk=; b=GDACx3lXnTlQztxEJh8HjSNU7UMGydgjz1UwOb/N84Z1OHmpY5Cr1NJ96x0XsYHKo0 +0lJzrcNibVrQ0hgHAGM1eugbwnp0jA9lS70mn6a0XIG26suxsscuyJ5mkcP6neozLIm dY/fzZhWQ+3fUB/iWkHpyUqc82PaT9HI1TOruyWSGvDkScKOPCJJB1owS95ueYwA4UiI uj1vXAjTo4lBhYtTDu3dUs8+C/9YjkbTOEyU8YNViJfVqvF67Za72AmImOUrlFFsIV88 2oHqj3iJtWbbTtBmrIvBVmGhqBJ3s5+g7lRT7AVWSpumt/Z+mPrpbh+qA0SbWJR04S4/ XIIA== X-Gm-Message-State: ALyK8tJhU75FENgICbRXwhejf1u4CZJQqJzv/okYiuu0+lHqco1tlf62vmOFlrVqGpenglxYEWVbxSHJQSt3OA== X-Received: by 10.28.127.6 with SMTP id a6mr8134917wmd.95.1464560352111; Sun, 29 May 2016 15:19:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.163.106 with HTTP; Sun, 29 May 2016 15:18:52 -0700 (PDT) In-Reply-To: References: Date: Mon, 30 May 2016 00:18:52 +0200 Message-ID: To: "Colin O'Dell" Cc: PHP Internals , Jeremy Mikola Content-Type: multipart/alternative; boundary=001a1141ef9c8a32dd05340287c3 Subject: Re: [PHP-DEV] [RFC Discussion] array_change_keys() From: ocramius@gmail.com (Marco Pivetta) --001a1141ef9c8a32dd05340287c3 Content-Type: text/plain; charset=UTF-8 A bit skeptic here: 1. could you also provide the code for the benchmarks? I'd gladly measure them with an accurate tool 2. do we really need another array function that is basically an `array_combine(array_map($someFunc, array_keys($arr)), $arr)`? 3. and... do we really want another function that accepts arrays and not generic Traversable (and therefore also generators)? 4. what is the real-world benefit over just `array_combine(array_map($someFunc, array_keys($arr)), $arr)`, except for the two additional function calls here? Cheers, Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On 29 May 2016 at 15:13, Colin O'Dell wrote: > Hello everyone, > > I'd like to introduce a new RFC for your consideration and discussion: > https://wiki.php.net/rfc/array_change_keys This would add a new function > named array_change_keys() which simplifies the process of re-keying an > array. > > PHP currently has an array_change_key_case() method, but this only allows > keys to be changed to upper- or lower-case; no method exists to change the > keys to some custom user-defined value. Although it's absolutely possible > to accomplish this without a special function, the alternate approaches > have several drawbacks: > > - Slower execution time compared to the proposed implementation. > - Multiple lines and/or function calls are required. > - Harder to understand the code's purpose with a quick glance. > - The result of a "foreach" approach cannot be passed into another > function without using an intermediate variable. > > A working implementation has been included with the RFC (huge thanks to > Jeremy Mikola for the heavy lifting here!) I've also requested this patch > be added to 3v4l.org; I'll notify everyone if/when that happens. > > I'd greatly appreciate if you could review this RFC and let me know your > thoughts. I'd be happy to answer any questions you might have. > > Regards, > > Colin O'Dell > --001a1141ef9c8a32dd05340287c3--