Req #10429 [Com]: Add options for start/end strings for substr()
| From: | ppasindud at gmail dot com | Date: | Thu, 15 Jan 2015 13:47:20 +0000 |
| Subject: | Req #10429 [Com]: Add options for start/end strings for substr() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-189971@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=10429&edit=1
ID: 10429
Comment by: ppasindud at gmail dot com
Reported by: sbergmann@php.net
Summary: Add options for start/end strings for substr()
Status: Open
Type: Feature/Change Request
Package: Strings related
Operating System: *
PHP Version: *
Block user comment: N
Private report: N
New Comment:
Wouldn't this be a Feature/Change Request and require RFC
Previous Comments:
------------------------------------------------------------------------
[2001-04-21 05:09:31] sbergmann@php.net
I am currently using the following PHP Code to get a substring from a string, that is delimited by
two given strings, $start and $end:
function my_substr($start, $end, &$string) {
$start = preg_quote($start);
$end = preg_quote($end);
preg_match("#$start(.*?)$end#", $string, $result);
return $result[1];
}
It would be great if PHP's substr() function could handle operations like this, by changing its
signature accordingly, maybe to
string substr (string string, mixed start [, mixed end])
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=10429&edit=1