Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62207 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5383 invoked from network); 15 Aug 2012 20:35:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Aug 2012 20:35:59 -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:41893] helo=mail-we0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 16/16-08779-E280C205 for ; Wed, 15 Aug 2012 16:35:59 -0400 Received: by weyr1 with SMTP id r1so1487969wey.29 for ; Wed, 15 Aug 2012 13:35:55 -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=S82mkiZXxL8rA8ZU/bC2RotYFh1TCgkeHVSwZFLBpYA=; b=fWI9SaE0VN8kjLd8srt8M+Zkia/B2TrZ4glG97xWsKcXlSEuLs8kSdxO+0jGfEtBbl 38omVzWdbGHY6En2jDL4Hb7vHQ2/cQdtIX+DlyruGStZ+rexCCO3I/1iZ7DhIBBuz0wo p1jeF7htK7/6dnt9/Fyf67NRni5/hJTq1lfEHseiQSc8EdEpFWs0sIlrzMmb1uw7kIO0 mFV5YnpEWScJayBe6tHX8PEzHFmTFNs9sZGtVpayV4CrPpyaMxpm0qVEHaNdTwjDGvCB DcPshqnr+K4wWgpvqrg59B5NTaN2Sipmd0e9UoTGxLOd2g69dUPrEKfJCyJvWrpclcEu SXvw== MIME-Version: 1.0 Received: by 10.180.82.164 with SMTP id j4mr39640605wiy.18.1345062955735; Wed, 15 Aug 2012 13:35:55 -0700 (PDT) Received: by 10.216.211.30 with HTTP; Wed, 15 Aug 2012 13:35:55 -0700 (PDT) In-Reply-To: References: <502C04FB.2010000@sugarcrm.com> Date: Wed, 15 Aug 2012 13:35:55 -0700 Message-ID: To: Nikita Popov Cc: Stas Malyshev , Rasmus Schultz , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=f46d04428d96ad5c5b04c753df44 Subject: Re: [PHP-DEV] removing an item from an array From: kris.craig@gmail.com (Kris Craig) --f46d04428d96ad5c5b04c753df44 Content-Type: text/plain; charset=ISO-8859-1 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 --f46d04428d96ad5c5b04c753df44--