Req #60630 [Opn]: I'd like to see two functions added to php: str_begins_with and str_ends_with
| From: | pajoye@php.net | Date: | Sat, 31 Dec 2011 12:15:44 +0000 |
| Subject: | Req #60630 [Opn]: I'd like to see two functions added to php: str_begins_with and str_ends_with | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-166154@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60630&edit=1
ID: 60630
Updated by: pajoye@php.net
Reported by: regality at gmail dot com
Summary: I'd like to see two functions added to php:
str_begins_with and str_ends_with
Status: Open
Type: Feature/Change Request
Package: *General Issues
Operating System: Linux
PHP Version: 5.4.0RC4
Block user comment: N
Private report: N
New Comment:
substr allows that very easily, for example with negative offset for the end with
part of your request.
Previous Comments:
------------------------------------------------------------------------
[2011-12-31 12:08:51] 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.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60630&edit=1