Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66091 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66066 invoked from network); 21 Feb 2013 08:03:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Feb 2013 08:03:09 -0000 Authentication-Results: pb1.pair.com smtp.mail=krebs.seb@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=krebs.seb@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.41 as permitted sender) X-PHP-List-Original-Sender: krebs.seb@gmail.com X-Host-Fingerprint: 74.125.82.41 mail-wg0-f41.google.com Received: from [74.125.82.41] ([74.125.82.41:42333] helo=mail-wg0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EB/89-03224-CB4D5215 for ; Thu, 21 Feb 2013 03:03:08 -0500 Received: by mail-wg0-f41.google.com with SMTP id ds1so318148wgb.0 for ; Thu, 21 Feb 2013 00:03:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=l3pKnyp+sp4v4RKSUq87HuV7HdShahrzNIn5J3fQWHE=; b=g0QjGFR+g1qU6YkQWRoE9tukGp9tiaG20LeLlqsy9Hqq1BF2bM8FJ5d2xlJqhaVMiK yJ9/ZIg5l6U+UeGltIY2g6yeEf0PZNsxr403RTNbEpcnQp4QOP5VUSz7oD5R8n4KzA5k cQ2obfXAH4TfNj8JKQKJuBEQXqAE1uYdSIMF+2xVdNn0NgKAcAEu1gdH298tbfBwJCzF PsOTP/FkNddx3CNWkZGIRbkhUOvYSZP4dctBKsIWWPaz8uDMD4RZNrubpYPlPxIB5lZD NTEtpsjtK9vsKaQscaVe5v3PyKcoUuCkewImMSO1RuTAPwcUasCqbVBE/c57JBIkcXs+ UHoA== X-Received: by 10.180.107.196 with SMTP id he4mr29747253wib.21.1361433785511; Thu, 21 Feb 2013 00:03:05 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.98.197 with HTTP; Thu, 21 Feb 2013 00:02:44 -0800 (PST) In-Reply-To: References: Date: Thu, 21 Feb 2013 09:02:44 +0100 Message-ID: To: Tjerk Anne Meesters Cc: PHP Internals Content-Type: multipart/alternative; boundary=e89a8f2349812baf3b04d63781fb Subject: Re: [PHP-DEV] Pull request for array_filter() improvement From: krebs.seb@gmail.com (Sebastian Krebs) --e89a8f2349812baf3b04d63781fb Content-Type: text/plain; charset=ISO-8859-1 2013/2/21 Tjerk Anne Meesters > 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. > Hi, Why not simply _always_ push the key to the callback? Regards, Sebastian > > 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 > -- github.com/KingCrunch --e89a8f2349812baf3b04d63781fb--