Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121353 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 28878 invoked from network); 17 Oct 2023 16:19:47 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Oct 2023 16:19:47 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 12934180044 for ; Tue, 17 Oct 2023 09:19:46 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS9370 160.16.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail.sakiot.com (mail.sakiot.com [160.16.227.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 17 Oct 2023 09:19:45 -0700 (PDT) Received: from smtpclient.apple (softbank060067217005.bbtec.net [60.67.217.5]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by mail.sakiot.com (Postfix) with ESMTPSA id 72005401F9; Wed, 18 Oct 2023 01:19:42 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sakiot.com; s=default; t=1697559582; bh=Kh9BnWfXgRRyAc1fy6k9PTDPtZrEcTCbaC1PSufv6ZA=; h=From:Subject:Date:References:Cc:In-Reply-To:To:From; b=xBa8/U2SwXMheU78R29KHYDF87m7xUe9s+WksZA6gewG5H0VgNZzzcW2bQC9ho59J tYfrRB6GmLTcVPOJhHyQO0XllA5X1Z4c5BX1GimbQvw+6Ex+D+tVfQUMneq+UFF+cq pjOd3uN3yD67hqMP0aNHiUBS7upPSOoSr9hTZTb4= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (1.0) Date: Wed, 18 Oct 2023 01:19:30 +0900 Message-ID: <689F8F05-7E60-4D47-BE5B-B346891F6F79@sakiot.com> References: <0e05d40c-8574-4fd1-9d73-d6434fc6a2c3@betaapp.fastmail.com> Cc: Levi Morrison , David Grudl , Levi Morrison via internals In-Reply-To: <0e05d40c-8574-4fd1-9d73-d6434fc6a2c3@betaapp.fastmail.com> To: Michael Cordover X-Mailer: iPhone Mail (21A360) Subject: Re: [PHP-DEV] Two new functions array_first() and array_last() From: saki@sakiot.com (Saki Takamachi) > What about a signature like: >=20 > ```php > array_first(array $array, mixed $value_if_missing =3D null); > ``` >=20 > That would let you specify your own sentinel (or default) where appropriat= e, without losing the convenience of this function. This is a problem that should be addressed in your application. ``` array_first($arr) ?? $initial ``` I personally think we should make the effort to write it this way and not ha= ve to support initial values =E2=80=8B=E2=80=8Bat the language level. Regards. Saki=