Re: Adding in a case-insensitive version of str_contains

From: Date: Thu, 29 May 2025 23:31:22 +0000
Subject: Re: Adding in a case-insensitive version of str_contains
References: 1 2  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On 29 May 2025 22:00:00 BST, Kamil Tekiela <[email protected]> wrote:
>As I understand, it was a conscious decision not to add this function
>when str_contains was created. The reason is that case sensitivity is
>locale-dependent, and for such use cases, mbstring extension is better
>[1] & [2]. Do you think that locale is a concern here, and if not,
>why? Would it be a good idea to add mb_str_icontains instead?

mbstring doesn't deal with, or handle, locales, only charactersets. So that wouldn't be a
good fit either. 

There is grapheme_stripos, but that also doesn't do it locale dependent: <https://www.php.net/manual/en/function.grapheme-stripos.php>

PHP could really do with a locale aware, grapheme aware, set of Text utilities. 

I have a prototype at <https://github.com/derickr/php-text> where this
suggested function also would fit in. 

cheers 
Derick 


Thread (10 messages)

« previous php.internals (#127506) next »