Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102314 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36100 invoked from network); 20 Jun 2018 02:47:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jun 2018 02:47:17 -0000 Authentication-Results: pb1.pair.com header.from=levim@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.46 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.215.46 mail-lf0-f46.google.com Received: from [209.85.215.46] ([209.85.215.46:37158] helo=mail-lf0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1A/60-32156-530C92B5 for ; Tue, 19 Jun 2018 22:47:17 -0400 Received: by mail-lf0-f46.google.com with SMTP id g21-v6so2563625lfb.4 for ; Tue, 19 Jun 2018 19:47:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=er/d+jKQRBOfgtzCRq6mexlRiNhEGGGVUTHTnL2aT7s=; b=Mbjnn+NzpcSJcJ/PpOndf2P9xQqBgfSk+9/6WN9hwtBQIxXsD6o8QUmVTbf0ElJBRb ttef+Ee5K5rLDeWq8aJsy39v+m5M/0KrKbBDpuEqa67UxFvhbQX1iQAjIAPrTa2NK0LW sqPBJwaJQUIAjigUc/G3PsYTHM4x/6gtzicoUjWlx7/zgYwkDCSqkyuXAZ0cc0u+4FT+ oJ+YlvjLo4/6CSrKu+hsr8eS89big95XbWK3dktd8cprqZrDeS9udvUPj+g4cZ2XW6zt W4xLhgbsQUpVPXCmPi1LeGhYaU45ZEw9H6+wQZjwMPlG63gaNGmnE5oTvbzmpVUmZC6l qDmw== X-Gm-Message-State: APt69E06b0xwqTTTYyXzmJflHE3ivGkmgbcwS7p+odQrxRZdwKlCE2ov mVS7DNV2MOzOEboL3L0yzYV7+eFmSbOppmKMR3B+gJyk X-Google-Smtp-Source: ADUXVKJpNZ6/gni12wSO5+PBm1RRAlnVtCsso76hwJWM+YsWVr+8Uk4isDYc+MvGNaDKXErG1Phqt3OwOKas69Gw3bM= X-Received: by 2002:a19:fc15:: with SMTP id a21-v6mr8080731lfi.82.1529462833756; Tue, 19 Jun 2018 19:47:13 -0700 (PDT) MIME-Version: 1.0 References: <75db877c-ef0b-7d3b-48a8-9879d90352b0@web.de> <76e4744f-6722-ee49-0325-e4433236f1b1@web.de> <73ac8914-8c9f-e74b-a4f5-f6e39cd96f8f@gmx.de> <3242366.BL9MUqXe46@vulcan> In-Reply-To: <3242366.BL9MUqXe46@vulcan> Date: Tue, 19 Jun 2018 20:47:01 -0600 Message-ID: To: Larry Garfield Cc: internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC][Under Discussion] Add functions array_key_first()and array_key_last() From: levim@php.net (Levi Morrison) I don't think I'm getting all the mail I am supposed to. I hope this gets seen. I propose 2 functions *only* which I believe covers the use-cases that all 4 of these do and more, with shorter names, and the ability to discern whether the call succeeded or not. list($key, $value) = array_first($input); // $key will be null if the call failed list($key, $value) = array_last($input); // $key will be null if the call failed I have tested it with user-land functions and seems to work as intended in all success and failure conditions. Verification that it works as intended with internal functions is necessary but this seems a much better proposal to me.