Re: [PHP-DEV] [RFC] [Discussion] array_match

[email protected] (Christian Schneider)
Newsgroups php.internals
Message-ID <[email protected]>
Am 22.08.2026 um 22:31 schrieb ⁨سپهر محمودی⁩ <⁨[email protected]⁩>:
> Additionally, I have entirely removed the 3rd parameter (`$ignore_case`). You made a great point regarding the ASCII/Unicode complexities, and considering the history with the rejected `str_icontains` RFC, it makes sense to drop it and keep the behavior strictly aligned with `str_contains()`.
> 
> I have updated the RFC to reflect these changes (Version 0.3):
> https://wiki.php.net/rfc/array_str_contains

Why not use preg_grep which basically does the same thing (and would support both case insensitivity and Unicode)?

Sure, you need a delimiter and if you have special characters in your $needle then you need to use preg_quote but for all your examples but your function basically boils down to
function array_str_contains($haystack, $needle) { return preg_grep('/' . preg_quote($needle, '/') . '/', $haystack); }

I don't think it is worth adding this to the already quite large list of array_-functions.

Regards,
- Chris
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.