|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2001-04-21 05:09 UTC] 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])
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 17:00:02 2025 UTC | 
Changing a function as important as substr could very well need an RFC. There is a problem to confront first: substr("string", "0", "5") is ambiguous. On the other hand a brand new function, maybe named according to the substr_* pattern already in place, wouldn't be that difficult and shouldn't require an RFC... Compare with MySQL's SUBSTRING_INDEX function. http://dev.mysql.com/doc/refman/5.6/en/string-functions.html#function_substring-index