Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121346 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 2164 invoked from network); 17 Oct 2023 09:37:34 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Oct 2023 09:37:34 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 127DF180504 for ; Tue, 17 Oct 2023 02:37:33 -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,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.46]) (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 02:37:32 -0700 (PDT) Received: by mail-oo1-f46.google.com with SMTP id 006d021491bc7-581cb88f645so424064eaf.1 for ; Tue, 17 Oct 2023 02:37:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697535452; x=1698140252; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=dwMzX1mfJvKQXLyv1LlJo1ZJBq4PpnoBLr+5SkfvNxQ=; b=kJ+tgEqKitfltRXbPqsS2WimFgCUUCU3H0ljIPt9lz4kmL/xIsy1qLpGsiP19m8Sk+ nAaGY1ea2VpvDNBEvumt9gTPkeOHjQrPIlhtsXOKfJfusYtFhztatZPoJ4pjRxgRTPrM tYMAFhkO71nrDB9e9oZzoECK4MNkLeprkmVHlN4x/AP1tckX6E4dj+wfC2XB1CQJr6ua LuwY2SevKI8X4GnMS3tNoWCdmHdn1/43/Egcx1pr4StRExKDnmOfXUaGdzq9Mf+RhJMF Qsm5nfUVlcyMZbxT2lgqCo9ZTf0AsdPLqtTN2VPtiiGQ0WsCvPvTCqKQkWmagERUcc1N qtGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697535452; x=1698140252; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dwMzX1mfJvKQXLyv1LlJo1ZJBq4PpnoBLr+5SkfvNxQ=; b=ijPfAufrn+aLzfAek1s9G8N/O831g0sdVv8Hqs2X2O+FzxCpzzZkDY2Bf/sTscN1P5 Zaml9VnSnZb6ZCewt9rYxkNwwYpiliqNKB6JvRwOFd4+5RpUd2CbH4k8H6SBcki34QNQ ZwdaKCvCvgFfL/tLSJDt6mzWhbQBQDO73Rquq1Mge1U1yEiLKKcOZz/DPkdt9E07najj Y2FqgTV4+9J8DmTZVe9UGjv7HEgVLLqT924c3fRtzCNWNyHIVSVdjCdRCDRnOwyI4uYN fDUpilYcGch4af8fANWoe3flEs05uOLCSbLyv0Oigt7ri0m0+x8oWxpF1KtakI6BpIMd G3wQ== X-Gm-Message-State: AOJu0YxexT8Z+BNpUwKEfdx01bJFlilDnP0yji8FiLPPvUC4zyUxovay iqz2atpHyqq6wKce5kw66CUuIyeG7OWkaZ1ZbPX2pMwd9QdeWQ== X-Google-Smtp-Source: AGHT+IF+r5I4nxDLM20iLmk+mDG5F6l2tvcJUn2MXeJB4eOfDgYcBMcUGG9CbqpL23fO0XOJy7ukS5ML5c4su/+tUa8= X-Received: by 2002:a4a:d757:0:b0:57b:6a40:8a9e with SMTP id h23-20020a4ad757000000b0057b6a408a9emr1585551oot.7.1697535452220; Tue, 17 Oct 2023 02:37:32 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 17 Oct 2023 11:37:20 +0200 Message-ID: To: Aleksander Machniak Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Two new functions array_first() and array_last() From: landers.robert@gmail.com (Robert Landers) On Tue, Oct 17, 2023 at 11:34=E2=80=AFAM Aleksander Machniak = wrote: > > On 17.10.2023 11:29, Robert Landers wrote: > > $value =3D array_value_first($array, $key); > > if($key =3D=3D=3D null) // handle error > > else // do something with $value > > > > You can also freely ignore the key, if you don't need it or care about > > error checking. That would save doing two function calls on the same > > array, just to do some error checking. > > > > Please, no. What's wrong with count() or empty()? > > +1 for array_first() and array_last(). The only problem is probably a > big BC break. I myself have array_first() defined in my framework. > > -- > Aleksander Machniak > Kolab Groupware Developer [https://kolab.org] > Roundcube Webmail Developer [https://roundcube.net] > ---------------------------------------------------- > PGP: 19359DC1 # Blog: https://kolabian.wordpress.com > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > Hey Aleksander, > Please, no. What's wrong with count() or empty()? Nothing. Why not either one? You don't have to use the $key variable and you can use count() or empty(), but for me personally, it makes a lot of sense.