Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62323 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10046 invoked from network); 20 Aug 2012 23:53:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Aug 2012 23:53:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-we0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:65379] helo=mail-we0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E5/83-28202-BEDC2305 for ; Mon, 20 Aug 2012 19:53:16 -0400 Received: by weyr1 with SMTP id r1so4922185wey.29 for ; Mon, 20 Aug 2012 16:53:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=weZcxUxOASVYQ6VRDamZW6YeNtT2aWldKvXsIWzJUPs=; b=c5DDT/T+EDhnRp/VZruYjJcezDof6qXpeaiFXOEu4jdiL7eGX8qGB2OIdCOHhWOY6y 2yevqbOT23KZKk0uFvHTBduCMJpamNNUSYjA9uTpc1B2ymjxEkqb+/htBlRwGoM6xg4S UYdkj2CRMXMi8T4ECf+P9n3ubr3iX32RY+SiQV9JfoY2Ik7/n163DRNuSd6qsl0VV14i TccrN2yRrtljir8EJMZiibE+AWuTSisqYc1ES+gty+hX45LgmI6EDIbcR11Bn/V48v7R 8Up6hPDN7Wkui/IYk829rjLJax5HHxK8uoSYJeKPKtqfaqWZGbf+plAQwdRZ/6XaUuKM 9xHw== Received: by 10.180.100.133 with SMTP id ey5mr11113677wib.4.1345506791668; Mon, 20 Aug 2012 16:53:11 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.223.86.201 with HTTP; Mon, 20 Aug 2012 16:52:31 -0700 (PDT) In-Reply-To: References: <502EB667.1020602@lerdorf.com> Date: Tue, 21 Aug 2012 08:52:31 +0900 X-Google-Sender-Auth: H706LsnK9e_O3gu8sviIH3R0alQ Message-ID: To: Herman Radtke Cc: Etienne Kneuss , Rasmus Lerdorf , Rasmus Schultz , internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] re: removing an item from an array From: yohgaki@ohgaki.net (Yasuo Ohgaki) Hi, 2012/8/21 Herman Radtke : >>> May be we should have something like >> >> >> >> >> array_delete_if($array, function($v, $k=null) { if ($v == 300) return >> >> true; }) >> > >> > So array_filter? >> >> I'll use it or like for deleting, but the point of this thread is >> "intuitive function for deleting element(s)" >> >> array_delete($array, $value|callable) >> >> would be nicer for users, perhaps. > > > You are basically asking to alias array_filter with "array_delete". That is > a very slippery slope. I think array_filter is very a very obvious choice to > remove something from an array. The "filter" function/method is common in > functional languages (and functional frameworks like Underscore). > > These are things developers just need to learn as part of development. > Really, this is entire thread should be on stack overflow, not internals. I guess you haven't read later post. You've also made a novice mistake. array_filter() DO NOT delete elements, but creates new array. array_delete() is another form of array_walk(), not array_filter(). See my posts. Having a API for dedicated task is good thing. Who would argue array_pop()/array_push() isn't needed? Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net