Re: [VOTE] Voting opens for str_starts_with and ends_with functions

  106162
July 8, 2019 10:15 andrewgrom@rambler.ru ("Andrew Gromov")
> For those voting against adding these functions, can you clarify why? > Do you dislike how they are named, or do you not see the need for the > case insensitive versions, or is there an issue with the implementation?
I believe that star_with/end_with is useful, but not in this form. The standard library has 98 string functions with different naming styles. Adding 4 more (8 for mb_) functions for actually two(one?) tasks is redundant. I think that more discussion is needed. My preferred variants: 1) One function ```php str_contains( $haystack, $needle, [CASE_INSENSITIVE|FROM_BEGIN|FROM_END|MULTI_BYTE] = 0, [$encoding] = utf8 ) ``` 2)Or two ```php str_starts_with(...see above, but without FROM_BEGIN|FROM_END) str_ends_with(...see above, but without FROM_BEGIN|FROM_END) ``` Best regards,Andrey
  106164
July 8, 2019 11:30 ocramius@gmail.com (Marco Pivetta)
On Mon, Jul 8, 2019, 12:15 Andrew Gromov <andrewgrom@rambler.ru> wrote:

> > For those voting against adding these functions, can you clarify why? > > Do you dislike how they are named, or do you not see the need for the > > case insensitive versions, or is there an issue with the implementation? > > > I believe that star_with/end_with is useful, but not in this form. > The standard library has 98 string functions with different naming styles. > Adding 4 more (8 for mb_) functions for actually two(one?) tasks is > redundant. > > I think that more discussion is needed. > > My preferred variants: > > 1) One function > > ```php > str_contains( > $haystack, > $needle, > [CASE_INSENSITIVE|FROM_BEGIN|FROM_END|MULTI_BYTE] = 0, > [$encoding] = utf8 > ) > ``` > > 2)Or two > > ```php > str_starts_with(...see above, but without FROM_BEGIN|FROM_END) > str_ends_with(...see above, but without FROM_BEGIN|FROM_END) > ``` > > Best regards,Andrey >
Please don't switch behaviours via flags: separate names and implementations are much clearer and much simpler to follow. Yes, you will have multiple variations, but that's fine.
>