Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46594 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95648 invoked from network); 2 Jan 2010 20:36:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Jan 2010 20:36:11 -0000 Authentication-Results: pb1.pair.com header.from=kalle.php@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=kalle.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.213 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: kalle.php@gmail.com X-Host-Fingerprint: 209.85.218.213 mail-bw0-f213.google.com Received: from [209.85.218.213] ([209.85.218.213:64584] helo=mail-bw0-f213.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D9/A1-12956-A3EAF3B4 for ; Sat, 02 Jan 2010 15:36:11 -0500 Received: by bwz5 with SMTP id 5so8749463bwz.23 for ; Sat, 02 Jan 2010 12:36:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type; bh=yiUOxr9UJVsNJsmeu0ZDwn10rqJ46T4L6NGnVgHnK5U=; b=xkU2/Z8l4GfQyXNW3ofWi5yAzT5Ky9Gn45LP/Z+v6cKiX/LSb2tB+bL4sILBR4W49s B+ua2nLgNNZCd+MykUtEd+TabQXNoqetID1MHmL0K8sRRsYjsw8ywlaSzG3ruU/R0Vvt zoUHTPjVgXcIgsBqUvhHPW1o5GtLDkF96Ghfw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=OFGD02/cfBXbbGfATAxjIhY7TccQ5xW5sobGUrC2JB4g+IlMqThqUi8xmAEgn444PT ugZMQFJydDeWYn5Qz1l6EISL52iASBHiItzz5MGbz9KKYPIVt+S87kHSk4yBboRzAbXy cLWYeyjNww7bfxOvcJfnBR2hgOoHv8n01fq2M= MIME-Version: 1.0 Sender: kalle.php@gmail.com Received: by 10.204.15.138 with SMTP id k10mr3968485bka.101.1262464567979; Sat, 02 Jan 2010 12:36:07 -0800 (PST) In-Reply-To: <4B3F788E.7090200@gmail.com> References: <4B3F788E.7090200@gmail.com> Date: Sat, 2 Jan 2010 21:36:07 +0100 X-Google-Sender-Auth: ee96e678dd1a274d Message-ID: <2dedb8a1001021236i19571279tf6fc4b57664ca2b@mail.gmail.com> To: Oskar Eisemuth Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] array position isfirst / islast / valid ? From: kalle@php.net (Kalle Sommer Nielsen) Hi Oskar 2010/1/2 Oskar Eisemuth : > Hello > > Would it be possible to add functions to know the relative internal array > position? > > I found "[PHP-DEV] RFC array functions" from 2006, but nothing really > changed. > > The need to use next, prev in combination is ridiculous compared to a clean > array_hasmore or array_pos_islast, as the internals already know this. > To get an array_valid_position or array_pos_isvalid wouldn't be bad either. > > So would it possible to introduce: > How about just array_pos() if any. The remaining functions can easily be implemented in userland like: function array_pos_isfirst(Array &$array) { return array_pos($array) == 0; } function array_pos_islast(Array &$array) { return array_pos($array) == (sizeof($array) - 1); } I don't think it should be needed to add array_pos_isvalid(), since it *shouldn't* be possible to point to an invalid position. Rather "isset($array['key'])" should be used to check if a position is valid. -- regrads, Kalle Sommer Nielsen kalle@php.net