Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62382 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88840 invoked from network); 22 Aug 2012 01:46:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Aug 2012 01:46:42 -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 209.85.212.176 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.212.176 mail-wi0-f176.google.com Received: from [209.85.212.176] ([209.85.212.176:45823] helo=mail-wi0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 47/01-10139-10A34305 for ; Tue, 21 Aug 2012 21:46:42 -0400 Received: by wibhn17 with SMTP id hn17so4365000wib.11 for ; Tue, 21 Aug 2012 18:46:39 -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=5HjQbaY0byjqL0obkvyrtYNoH6B4WRypf84pus49VHk=; b=EdcK57ckFUsOlghTY6U0Oe+g2JSP5FbCHhabCbjPVyDyEJojHEaoRFvlnTHcrBsYhy 1+k8Lr17jOh9nesKwrZzZ9msaxEY/29TzAvyw+TE6y8ISv6oPs/prKtn8vW8Dlmc3tyW q3a3Jh1Ozr1j4ZSmFfY4Xn+LayzaJB9KApXtS5K/OTqrYdzzOp1iBfG02wV/zrzOC5Dq rVyfAjtpnil0TXo1uDSkyhUxTbVQ76r6cLgFVrBzHnJOHpIRxaIljZ0ywpSEG4l5fUgr sP0Ww3PVu6psj3ZXLTLsVFNy69c0usdNWZUdZTojMlgyx6xtgePbynE5VJmeGND+CtnG 5zbQ== Received: by 10.180.104.200 with SMTP id gg8mr1560264wib.14.1345599999237; Tue, 21 Aug 2012 18:46:39 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.223.86.201 with HTTP; Tue, 21 Aug 2012 18:45:59 -0700 (PDT) In-Reply-To: References: Date: Wed, 22 Aug 2012 10:45:59 +0900 X-Google-Sender-Auth: XKRFbjFBnt241GGVxwH5yu_g4CY Message-ID: To: Rasmus Schultz Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] removing an item from an array From: yohgaki@ohgaki.net (Yasuo Ohgaki) Hi, 2012/8/16 Rasmus Schultz : > How come there is no straight-foward obvious way to simply remove a given > value from an array? > > Just look at the number of horrible ways people solve this obvious problem: > > http://stackoverflow.com/questions/7225070/php-array-delete-by-value-not-key > > Shouldn't we have something simple, like: > > array_remove($array, $value) : array (returns a new array) > > and/or > > array_delete(&$array, $value) : bool (modifies array directly) > > ? It was amazing that this thread has close to 90 mails. I've added some use cases of array_udelete() to wiki, since some people fails to see how it could be useful. I also bring back to array_walk() version of equivalent example. I just don't see any reason why we should replace it with slower foreach() version. I think the RFC page is almost complete. https://wiki.php.net/rfc/array_delete Any more comments? -- Yasuo Ohgaki yohgaki@ohgaki.net