Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130321 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 4ED741A00BC for ; Sun, 15 Mar 2026 09:15:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1773566106; bh=9Sk+2LTMgbXY2d9XPoRb8vOj063VYwaTCDEPIQap6yA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=h56apwE+rUd5qtmQIVHE40Eg9wpvmjTYlrpXK+1KjqEnSEnM6Tex3SAUO0Ca/26tZ WC4ahTc4H8wz8hwn12N3h7f3xWVmq6drBa8q4pnQWSf1s3ZPsicZLASeJ8S7QNztc5 U2g1BbREdY8kF+ysu+jdnXe3Z1rYjf3OAez48K23X+uZ1VvXFR3U6KfwqbecZfqixy SAEBfmTFTaqBJumE3q1SpoI5gRb2bDnvigxh4+j7TWp5bOOVQToEjaG+b9+Vh5BaJG OxyxdQYABo0SVv/36/mHHOCE3K5pkS6o2g55prLxXr2k293FQbRMpSFr2fK7mbqOEM KbZ++mJx+XBhg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 402BC180059 for ; Sun, 15 Mar 2026 09:15:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: * X-Spam-Status: No, score=1.6 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_50, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FORGED_GMAIL_RCVD,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 15 Mar 2026 09:15:06 +0000 (UTC) Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-89a0d53f3d1so47304606d6.3 for ; Sun, 15 Mar 2026 02:15:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773566100; cv=none; d=google.com; s=arc-20240605; b=OfMdoSsFowePIPlprt5mnk3hOOMFU+uLAN8zNqEXkLRadctBcKdHH4ckkQeGyl7LFc jTprsIAt8rx7O0mtq4iZQIGEFGxyx4877zxmOI6bIDqpHpVgqXBoorDWSjKxmJOH5PZG vqiVCycDUlEpoTDQX01uC70b31zDwTxWUPQ77EH0Cen7onhoH3d0kK7oJ85Sj7VP12/C iz1xXRE0BIF5HpoaPyz3vyqm46RWftyYC19m15aZz48RT8xGpknV29aiJGyAeeq8nLqe 3CnRh9pmOu/QAnao+LkGl1AWlF1nU+a/wfNosL2XQrCx7ql2lkX67S8HhNEwauFigoEF 3cuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=9Sk+2LTMgbXY2d9XPoRb8vOj063VYwaTCDEPIQap6yA=; fh=VmMcr0X+1lGz4ztwjjWlXxjP9XXO4flWKX7pjXmUAdA=; b=Po2h9IQM5gI1plP2CJYRSSToiXVI+xYnjuCc5OCjGr6mq4Fafp6XlkVuf3y/zxKphS 9Lh+TIGimfLCMJ96AP17KNp7uQbsoILplSU+8SAk8TpivPyUnj5C1DK7xS/meFwd4Ixo 1WBJSifsxfswa4/GXEeUd92jAbn3MPG/cMu65CusEHPIuqKvnRrkkUBNZxFgvdrLY7Ed llubsg/mTpuKndPP7XBRKQ9DIWaI9BkVcxthmxWrQQ7YIKTAwX7lWa3yvAnvId+GUb0v maXXOrMds5vV0QUDN2/bNK1xSQ9nRShT3Q+XFCw1yVbvib+yDI7ODP9Y+T0xtZ2WFeEv lkvA==; darn=lists.php.net ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773566100; x=1774170900; 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=9Sk+2LTMgbXY2d9XPoRb8vOj063VYwaTCDEPIQap6yA=; b=RFdObPIzAbAwKFfAfajpCM/1KAnpfgkJqMtBTaemPVB/DmUVUAkPgdjjju8WeyHb0A rMkDAkqt8e6uEj5xyZ75xg4JcBtc5Ow0wd86VTzIRKzo0tVUif0EfMVeIuZQP9TYudC6 RWnD9dAUWYMdWZYk51CZyF7qcdElXo5YU/LdmkcnCx0Qgk5Gss86YB4eQbH8HCkwe77D UQf7/AfD5eTumM29YlnyxoWuJLUutBw/lGk4XEZImRt7Egqus8mqsOXmgED5VoFTKM0Y lr/plduAEIYF3/3uXAS8T85F/L3vFvbKRFh0VfheNflYIKAZGNw4npDGM2KPLXo8V6CY XaFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773566100; x=1774170900; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=9Sk+2LTMgbXY2d9XPoRb8vOj063VYwaTCDEPIQap6yA=; b=AvhXj0VEY3c9FREJVHQJkvbi/vtmEWYHpgqPQ7LKx77bIO1nCPomZhZHITqAZbM53h ZXUxMHkWF01IhR9PTqZfB6wqlwKKvqqYceYbaPTrYokgG0YYDVRgnj4RZTfrpMZ4HU75 zaFYhjuDQr+yly1LWSNREqtmTPdehpuZItZIvNKzHBlVPsXg7d7qLPZUzbwJv5SB0yZO qHYFz5hMsILYdiTy4GOH86RjjuIH68ensRk6guYtXjQdDaWyt+oWMm7HKodzqJqSOdXO y+FD5Z0UbQuVc1fqsP719SB7zSmIH2kWC3O+vNLC1MPsDRWUB8w/HPD616pBKGLbf2aS x6jA== X-Gm-Message-State: AOJu0YxxY8OFjD4m1KESDE7MsH+7Y4KfqWFszB9YCWqbOYU1AmJ4h9Wi jedrEMb9AsFoNiCX4cbBleNtWXrvgUrYrkKS4Wo7Hy541EZC7mo3LJRuWnUH39tTdXLVTXK8/g0 WsnnH3M2DeW6Ivzc7oMbrMnAk/IGpIUY= X-Gm-Gg: ATEYQzwk7CHNfs8EpNofyT7PVu1+vad44sC5XAaN2LNXiOmKGQw3LXRk2vQURvnkS4c WLphyWoiBDp4I4J7yM/BjI+i9Tfe/kJm4vPd4nsYtIpBVNCHPkvq3U+XGSqbLe29pkOklGmujAP UYSGBWVUBpX2gWXN+YUrZY20JwIckdQbmdRlbQC7c7dXRXr8kjDJc/FgXeFpcxRMll/qo3OX4BE 316Ce+Exh+kmWWzVeYiPQC7IHvSTGW4QtFC1WQyOeD0T5j60H2j715QUkvHcitxEhd/Sm/hQ5Xc 7kggP6ISGIciCPzmz5wUrl106/FtWilcIM2PWA== X-Received: by 2002:a0c:e08d:0:10b0:89c:452e:ae9f with SMTP id 6a1803df08f44-89c452ec908mr22338316d6.54.1773566100315; Sun, 15 Mar 2026 02:15:00 -0700 (PDT) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <4203ACE0-03F4-457B-A542-C9FC2B72AE98@php.net> In-Reply-To: <4203ACE0-03F4-457B-A542-C9FC2B72AE98@php.net> Date: Sun, 15 Mar 2026 10:14:49 +0100 X-Gm-Features: AaiRm52Gd4bmryzKQHlBxFNulBWo3RNTz_FCtW-r9YLR6pHjJENqvKBVra5B19Q Message-ID: Subject: Re: [PHP-DEV] Array arguments for str functions To: Derick Rethans Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000006520f8064d0c89bc" From: barel.barelon@gmail.com (Barel) --0000000000006520f8064d0c89bc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, 15 Mar 2026 at 09:20, Derick Rethans wrote: > On 15 March 2026 08:20:38 CET, Barel wrote: > >Hi all, > > > >I would like to create an RFC proposal suggesting modifying the > >str_contains, str_starts_with and str_ends_with functions so that they c= an > >accept an array argument for the $needle parameter (apart from accepting= a > >string as they do now). If an array is passed and the $haystack string > >contains, starts with or ends with any of the strings in the array then > the > >functions will return true, otherwise returns false. > > > >I looked at the RFCs where these functions were added and at the related > >internal discussions and could not find any discussion about this > >possibility. > >Before creating the RFC I would like to hear the thoughts of the group, > >many thanks in advance > > > >Cheers > > > >Carlos > > The semantics for starts_with and ends_with are easy to argue they should > mean any element, but for str_contains it could be useful to have either > all, or any. > > I'm therefore thinking it might be better to have separate functions to > make this clear. > > cheers > Derick Thanks Derick, While =E2=80=9Ccontains all=E2=80=9D semantics can be useful in some niche = scenarios, I believe they are much less frequent than the "contains any" semantics. And =E2=80=9Ccontains any=E2=80=9D is the direct parallel to the proposed behav= ior for str_starts_with() and str_ends_with(), keeping the mental model consistent across all three functions. Would like to hear the thoughts of other people about this issue Cheers Carlos --0000000000006520f8064d0c89bc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sun, 15 Mar 2026 at 09:20, Derick Reth= ans <derick@php.net> wrote:
On 15 March 2026 08:20:38 CET, Barel <barel.barelon@gmail.c= om> wrote:
>Hi all,
>
>I would like to create an RFC proposal suggesting modifying the
>str_contains, str_starts_with and str_ends_with functions so that they = can
>accept an array argument for the $needle parameter (apart from acceptin= g a
>string as they do now). If an array is passed and the $haystack string<= br> >contains, starts with or ends with any of the strings in the array then= the
>functions will return true, otherwise returns false.
>
>I looked at the RFCs where these functions were added and at the relate= d
>internal discussions and could not find any discussion about this
>possibility.
>Before creating the RFC I would like to hear the thoughts of the group,=
>many thanks in advance
>
>Cheers
>
>Carlos

The semantics for starts_with and ends_with are easy to argue they should m= ean any element, but for str_contains it could be useful to have either all= , or any.

I'm therefore thinking it might be better to have separate functions to= make this clear.

cheers
Derick

Thanks Derick,

While =E2=80=9Ccontains a= ll=E2=80=9D semantics can be useful in some niche scenarios, I believe they= are much less frequent than the "contains any" semantics. And = =E2=80=9Ccontains any=E2=80=9D is the direct parallel to the proposed behav= ior for str_starts_with() and str_ends_with(), ke= eping the mental model consistent across all three functions. Would like to= hear the thoughts of other people about this issue

Cheers

Ca= rlos
--0000000000006520f8064d0c89bc--