> You can find all the use cases and examples detailed on the RFC page:
> https://wiki.php.net/rfc/array_match
>
> I look forward to hearing your thoughts and feedback on this proposal!


I'm thumbs down on this for a few reasons.

1. We already have `str_contains` function. It is more intuitive that
a false `strpos` call, and it makes an `array_filter` function clean
too.

```php
array_filter($values, static fn($value) => str_contains($value, 'foo'));
```

2. I think this is a quite narrow use case. Even the RFC text example
is arguably a poor use case for a `str_contains` check. When checking
file extensions, it should be a str-ends-with check rather than a
str-contains check.

3. Echoing what Yuya mentioned, the case sensitivity is quite
difficult to reach a consensus on, for the same reasons why
`str_icontains` RFC was declined. At this stage, I argue we should not
add case-insensitive switches to any new functions.

4. Functions like this tend to be incomplete; someone else might argue
for preserving array keys or filtering by array keys. We already have
`array_filter` that can do all of it in any way the caller wants.

5. Finally, and somewhat opinionatedly, the word "match" resonates
more with regular expressions. `preg_match` in PHP itself,
`String.match()` in JS, `re.match()` in Python, etc to name a few.

Thank you.
Ayesh.

Reply via email to