Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62384 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92394 invoked from network); 22 Aug 2012 02:14:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Aug 2012 02:14:33 -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:48980] helo=mail-wi0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 79/C1-10139-78044305 for ; Tue, 21 Aug 2012 22:14:32 -0400 Received: by wibhn17 with SMTP id hn17so4377288wib.11 for ; Tue, 21 Aug 2012 19:14:28 -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 :content-transfer-encoding; bh=sBn5J6URHRAzn/yAsgrANJrMeJ9Pu5k3OxYSTaXE5u0=; b=uU2fh8W++tS7jCN04mQqIzDZ5gLF64GDoeRmRucOcmT7OQXS1MMIMTPU5gmzqqYj4D b1Xp3IG3A830aKMWrifqGZD/+B2QeLqaZTD03edsiC1YuPPf0vG4/zBA16gT7xcqol+9 jI8FcbobFMpWzn1GE/Gwc5fBXMpFQHHOoUz3KCmuh02Cp939o4uUX+j4Rvv6TO+e6k7M krGGfNRJ62SUMmTWOzZNRLCKtXmkmt5HyKmkw3h/+nTeqhT+csc7AZbT/wMcUR34e2Cb BuTtbjhfwYUDjcfk7i5oTK/nvpyBFKEGLkKrwqWAPbeiy7CWzwOpkNAE7DBfFP8hROIy ZB0w== Received: by 10.216.181.195 with SMTP id l45mr10049926wem.52.1345601668747; Tue, 21 Aug 2012 19:14:28 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.223.86.201 with HTTP; Tue, 21 Aug 2012 19:13:47 -0700 (PDT) In-Reply-To: References: Date: Wed, 22 Aug 2012 11:13:47 +0900 X-Google-Sender-Auth: Xb7wz-IjJIjMw8kh-u3WMR6a0xc Message-ID: To: Levi Morrison Cc: Rasmus Schultz , internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] removing an item from an array From: yohgaki@ohgaki.net (Yasuo Ohgaki) Hi, 2012/8/22 Levi Morrison : > On Tue, Aug 21, 2012 at 7:45 PM, Yasuo Ohgaki wrote: >> >> Hi, >> >> 2012/8/16 Rasmus Schultz : >> > How come there is no straight-foward obvious way to simply remove a gi= ven >> > value from an array? >> > >> > Just look at the number of horrible ways people solve this obvious pro= blem: >> > >> > http://stackoverflow.com/questions/7225070/php-array-delete-by-value-n= ot-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 > > Take a look at: > http://php.net/manual/en/function.array-walk.php#refsect1-function.array-= walk-parameters > > Look at funcname parameter. Notice: >> Only the values of the array may potentially be changed; its structure c= annot be altered, i.e., the programmer cannot add, unset or reorder element= s. If the callback does not respect this requirement, the behavior of this = function is undefined, and unpredictable. > > I'm just going to change the behavior back when you switch it to > array_walk. It's less clear and technically undefined. Ok, then my commit to the doc was outstanding still. Old PHP was behaved badly with reference variables. I'll remove obsolete statement. I'll fix it later. Thank you. -- Yasuo Ohgaki yohgaki@ohgaki.net