Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66089 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58893 invoked from network); 21 Feb 2013 07:09:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Feb 2013 07:09:03 -0000 Authentication-Results: pb1.pair.com header.from=tjerk.meesters@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tjerk.meesters@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.182 as permitted sender) X-PHP-List-Original-Sender: tjerk.meesters@gmail.com X-Host-Fingerprint: 209.85.220.182 mail-vc0-f182.google.com Received: from [209.85.220.182] ([209.85.220.182:43667] helo=mail-vc0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 29/68-03224-D08C5215 for ; Thu, 21 Feb 2013 02:09:01 -0500 Received: by mail-vc0-f182.google.com with SMTP id fl17so5646750vcb.27 for ; Wed, 20 Feb 2013 23:08:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:sender:date:x-google-sender-auth:message-id :subject:from:to:content-type; bh=9SRPB3KfqGbRUGINQnCiB9idu/Kg7dKOuX0LVQHpDSU=; b=gqmbgljcjpD/Tk9AYIh7j8jWaHV7WilXSWkIZN0fJmAgnOD97K2z/ATeIFQ6cCmIm1 YFj1Kz7JPa1obrbiHreZW/CB0nB8ThI25nU2tDfuhnbhNbQpxnLoj7RTGZhz0aAWeTqx +asobT8YKBeuMmvWP/Od2d4qLk44SdWlI4E6cOiLn45rND2FRD5bFDbTS+kCGlrU22PY QIe7i0QPTogjxPy5I4womPXFVCx0uXi08JtG+NT3pPL4p3X54zDZlozO87JgVKEl44lO eVRc8Um8wQvN6ywkHEQUpqL5M/zbtZ1OjHYs7lqlQNthR07/fOnAoOjrqUG0ToXW9bS4 HsNw== MIME-Version: 1.0 X-Received: by 10.52.20.177 with SMTP id o17mr26795976vde.17.1361430539049; Wed, 20 Feb 2013 23:08:59 -0800 (PST) Sender: tjerk.meesters@gmail.com Received: by 10.58.107.143 with HTTP; Wed, 20 Feb 2013 23:08:58 -0800 (PST) Date: Thu, 21 Feb 2013 15:08:58 +0800 X-Google-Sender-Auth: 25XMxOStKVOzDlNqmPpyff2dyzY Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary=20cf307ca1e4aae40604d636bfce Subject: Pull request for array_filter() improvement From: datibbaw@php.net (Tjerk Anne Meesters) --20cf307ca1e4aae40604d636bfce Content-Type: text/plain; charset=ISO-8859-1 Hi, I found myself wanting a feature of array_filter() with which I can perform filtering based on the array key instead of the value. To scratch this itch, I decided to dive into C again and just add the feature. My proposal is to add a third argument to array_filter() that will send the array keys to the callback. function myfilter($value, $key) { return $key > 4; } array_filter([1, 2, 3, 4, 5, 6, 7], 'myfilter', true); // returns: [6, 7] The pull request can be found here: https://github.com/php/php-src/pull/287 If this is useful for the language as a whole, do let me know what else I should do to champion it. Thanks! -- -- Tjerk --20cf307ca1e4aae40604d636bfce--