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

Reply via email to