Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62208 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6702 invoked from network); 15 Aug 2012 20:37:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Aug 2012 20:37:57 -0000 Authentication-Results: pb1.pair.com header.from=kris.craig@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=kris.craig@gmail.com; spf=pass; 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: kris.craig@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-we0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:48776] helo=mail-we0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 25/66-08779-4A80C205 for ; Wed, 15 Aug 2012 16:37:56 -0400 Received: by weyr1 with SMTP id r1so1489297wey.29 for ; Wed, 15 Aug 2012 13:37:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=xqbOAmXeAkJgGLoOtsh7RH4A86cnQk496WFSfTSb0Kg=; b=hGwjJR+w7ndzYjudREaCfrrqid3PrspsXlFBYNnX6sRbn6OwXXCBtcqIFX7qPRsCQu AwsvieB5MWua1ogqQxwJvGD/4AkWnzj13wbk+Blk3Qostn3A4H+/D9TFIagNmJWme+BS 8KinvCBYjg+sRuXugSCO9G7ClhFHzza0zUcU63oQBUg7sIErV8V9EkNC9z/wL/VezXDt kCXxXHT293Y61POeNFj/ZsnkhejtFG1DbbZFraW64A6fStsOEZwF9I7Xv7eWn1Mt+deZ 8o422Gp+lMULyG7nnwqyOo5Q/ZIEBWX8a0PZQF/gIHWEIrz5v+t27A+ZVLMr9yZYyQSp 6VCw== MIME-Version: 1.0 Received: by 10.180.84.1 with SMTP id u1mr39665369wiy.15.1345063073418; Wed, 15 Aug 2012 13:37:53 -0700 (PDT) Received: by 10.216.211.30 with HTTP; Wed, 15 Aug 2012 13:37:53 -0700 (PDT) In-Reply-To: References: <502C04FB.2010000@sugarcrm.com> Date: Wed, 15 Aug 2012 13:37:53 -0700 Message-ID: To: Nikita Popov Cc: Stas Malyshev , Rasmus Schultz , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=f46d0444023ab10dc704c753e69c Subject: Re: [PHP-DEV] removing an item from an array From: kris.craig@gmail.com (Kris Craig) --f46d0444023ab10dc704c753e69c Content-Type: text/plain; charset=ISO-8859-1 On Wed, Aug 15, 2012 at 1:35 PM, Kris Craig wrote: > > > On Wed, Aug 15, 2012 at 1:31 PM, Nikita Popov wrote: > >> On Wed, Aug 15, 2012 at 10:29 PM, Kris Craig >> wrote: >> >> >> >> Btw, deleting all values (not just the first) is also very easy >> currently: >> >> >> >> foreach (array_keys($array, $delValue) as $key) { >> >> unset($array[$key]); >> >> } >> >> >> > >> > Even easier still, just do this: >> > >> > $array_var = array(); >> >> It's often overlooked, but array_keys has a second parameter that only >> returns the keys for a certain value: http://php.net/array_keys ;) So >> no, that does not clean off the whole array. >> >> Nikita >> > > If you re-initialize it by setting it to array(), then yes that most > definitely will clear all the values in the array. As far as I know, > array_keys() has nothing to do with that. > > --Kris > > Err nevermind, I think I misread what you were trying to do. If you want to only clear a certain value, then yes using array_keys() with a search value specified is the way to go. If you want to clear all values in the array period (which is what I thought you were saying), then re-initializing with array() makes the most sense. --Kris --f46d0444023ab10dc704c753e69c--