php.net |  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
Votes:3
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: regality at gmail dot com
New email:
PHP Version: OS:

 

 [2011-12-31 12:08 UTC] regality at gmail dot com
Description:
------------
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])

and 

  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.


Patches

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

Pull Requests

History

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

Cheers,
 [2017-09-15 17:16 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Package: *General Issues +Package: Strings related -Assigned To: +Assigned To: cmb
 [2017-09-15 17:16 UTC] cmb@php.net
Duplicate of bug #50434.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 11:01:28 2024 UTC