|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #60630 I'd like to see two functions added to php: str_begins_with and str_ends_with
Submitted: 2011-12-31 12:08 UTC Modified: 2017-09-15 17:16 UTC
Avg. Score:4.0 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: regality at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: Strings related
PHP Version: 5.4.0RC4 OS: Linux
Private report: No CVE-ID: None
 [2011-12-31 12:08 UTC] regality at gmail dot com
I would like to see to string functions added to php. I know they are easy to 
implement in userland, but it would be nice to have them in the core.
I coded them up and attached a patch.
The functions are:

  str_begins_with(string $haystack, string $needle [, $case_insensitive = false])


  str_ends_with(string $haystack, string $needle [, $case_insensitive = false])

I think they are pretty self explanatory, check if a string begins with or ends 
with another string.


str_begins_ends_with (last revision 2011-12-31 12:15 UTC by regality at gmail dot com)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-31 12:15 UTC]
substr allows that very easily, for example with negative offset for the end with 
part of your request.
 [2011-12-31 12:38 UTC]
However if you like to propose them, please write a RFC and a patch. The RFC 
process is described here:

 [2017-09-15 17:16 UTC]
-Status: Open +Status: Duplicate -Package: *General Issues +Package: Strings related -Assigned To: +Assigned To: cmb
 [2017-09-15 17:16 UTC]
Duplicate of bug #50434.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 21 05:01:30 2024 UTC