2025年5月30日(金) 16:20 Adam Cable <adamca...@gmail.com>: > > On Thu, May 29, 2025 at 10:00 PM Kamil Tekiela <tekiela...@gmail.com> 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? >> >> If you're going to propose an RFC for this, it would be a good idea to >> explain what the real life use case for it is. While str_contains is >> very useful for checking the existence of a byte-string within another >> byte-string, a case-sensitive check doesn't seem to have much use. >> >> [1]: https://stackoverflow.com/a/63121809/1839439 >> [2]: >> https://wiki.php.net/rfc/str_contains#case-insensitivity_and_multibyte_strings > > > Thanks for this. > > In terms of real-life cases, we deal with a lot of datafeeds and > user-contributed content. > We have lots of rules engines that categorise or display data depending on > the content contained (and sometimes these rules change from time to time). > So for example, we have a rule that if the string contains the word > "exclusive" that it's displayed in a certain way. > We can add a rule that says if (str_contains($text, "exclusive"))... and if > want to include the ability for sentences to start with the word "Exclusive" > we currently have to write like this (as we like functions to be truthy)... > stripos(" ".$text, $exclusive) OR str_contains(strtolower($text), "exclusive") > > I'd just find it useful to have str_icontains/stri_contains available as the > same ASCII-folding variant that we have for other functions.
Hi Surely, mbstring does not locale-dependency. And grapheme function also can not specify locale. (Default is no specify the locale) Perhaps, does grapheme function need to specify the locale? I thought so when I implemented the grapheme function. Regards Yuya -- --------------------------- Yuya Hamada (tekimen) - https://tekitoh-memdhoi.info - https://github.com/youkidearitai -----------------------------