[RFC] [Discussion] array_str_contains() for PHP 8.7
| From: | سپهر محمودی | Date: | Sun, 30 Aug 2026 14:19:23 +0000 |
| Subject: | [RFC] [Discussion] array_str_contains() for PHP 8.7 | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-132390@lists.php.net to get a copy of this message | ||
Hi everyone,
I'd like to start the discussion for a new RFC proposing the
array_str_contains() function for PHP 8.7.
Filtering arrays based on substring matching is something many of us write
on a regular basis, usually with boilerplate like:
$matches = array_filter($array, fn($item) => is_string($item) &&
str_contains($item, $needle));
This RFC proposes adding a native `array_str_contains(array $haystack,
string $needle): array` to the standard library to make this faster,
cleaner, and memory-efficient while preserving array keys.
You can check out the RFC and implementation details here:
- RFC: https://wiki.php.net/rfc/array_str_contains
- Pull Request: https://github.com/php/php-src/pull/23512
I'd really appreciate your feedback, thoughts, and suggestions. Please keep
all feedback and replies in this mailing list thread so we have everything
in one place.
Thanks,
Sepehr