Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121402 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 86031 invoked from network); 18 Oct 2023 15:47:15 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Oct 2023 15:47:15 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C923B1804B0 for ; Wed, 18 Oct 2023 08:47:14 -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,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,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-il1-f181.google.com (mail-il1-f181.google.com [209.85.166.181]) (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 ; Wed, 18 Oct 2023 08:47:14 -0700 (PDT) Received: by mail-il1-f181.google.com with SMTP id e9e14a558f8ab-3573e6dd79bso26952715ab.2 for ; Wed, 18 Oct 2023 08:47:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; t=1697644033; x=1698248833; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=TOuxHUIC63oQZuUmPd/x7e10P4iEPYgEAZmV0dxJC9o=; b=Va4Y3+ez/4J6DhZVoE973i2GYHpk2HZ1aC0HnKoob/yc2hXeLaMTqszUM5sCvmlff1 SeKHb34qHciznR5B7p8OnclCa5gMvXUe3njjyCn/ffX1EYFSws1toWUSvanOrz9ZJsnB TvS9z26hnQXfgvPEH71ME4SlZnon3lVgVMDf8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697644033; x=1698248833; h=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=TOuxHUIC63oQZuUmPd/x7e10P4iEPYgEAZmV0dxJC9o=; b=t6E+whhkcfl3cHt6OlLX6XGDjs731M6cGX9jpuF+VEqho2b5hGc91h/nfxfYm7efTy SbEZzqSJMvQgMkb0/5qfCZhxyFBgZV1xc6YJp8hYg5hXCVGzGtRi1C4rxpAMTm32V698 XwlVdl83UWspuXGI04h/1J9n4o9jvK8/9xJ1G49OnYAiPLf+rWJ7amIhzTDQAJNOKKZL WuPefXI4/ervqV8DBYsj2f/QcapBn8+6iPnRvpVYdQ5xe5FjqEUw8ciIP4fSclQyDnWN 8Qbc/DnY2D0OkzzHyPDO9XLVhZq8ua4c8KGXaIs6Vw1BQ7xM67F9w5cz2UkUxKU1H81y 9lew== X-Gm-Message-State: AOJu0YwpzkCKliH0qHAoxmVjHwhKbCN+oJC70XnDvW98YRqCkc2hZULz ZS8iB8I+jl6yGzgzDlwwKoP7ED0xQBVX7DtR3/Mvmw== X-Google-Smtp-Source: AGHT+IH3gdvHRep27S0qjspfyTXa5u+W4Osp2LFqbj635l7t8Tu6jmN0jJ8Pf6BVErPukatE3aBrqkDo58dJ2c0CERE= X-Received: by 2002:a92:ccd1:0:b0:352:749b:720e with SMTP id u17-20020a92ccd1000000b00352749b720emr5453521ilq.12.1697644033574; Wed, 18 Oct 2023 08:47:13 -0700 (PDT) MIME-Version: 1.0 References: <173ca550-71a0-4bd4-96f2-b64b6155115a@app.fastmail.com> In-Reply-To: Reply-To: Levi Morrison Date: Wed, 18 Oct 2023 17:47:02 +0200 Message-ID: To: Benjamin Morel Cc: Robert Landers , Deleu , Brandon Jackson , Saki Takamachi , Levi Morrison via internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Two new functions array_first() and array_last() From: internals@lists.php.net ("Levi Morrison via internals") > > This is simply not true, 0 is not always the first key in a list, > > especially after filtering it. Hence there is a need for this function > > in the first place. > > Just to clarify this point: If 0 is not the first key, then it's not a list. > After filtering a list, you get an array that may or may not be a list: > https://3v4l.org/VegUr I don't see how `array_is_list` is relevant to `array_first` and `array_last`. PHP arrays are ordered: $foo = [ "first" => 1, "third" => 3, ]; It would be perfectly fine to use `array_first` or `array_last` with `$foo`. I think probably you would use `array_key_first` and `array_key_last` so you also get the key and not just the value, but I don't see any need to reduce `array_first` and `array_last` to only be logical or correct with arrays that uphold `array_is_list`.