Add functions that work with suffixes and prefixes#20953
Add functions that work with suffixes and prefixes#20953carlos-granados wants to merge 2 commits intophp:masterfrom
Conversation
|
Hi @carlos-granados. Thanks for your proposal. I think the addition of new string functions is controversial enough to warrant an RFC. See https://wiki.php.net/rfc/howto. I'm foreseeing some disagreements on naming / namespacing, among other things. The |
Thank @iluuu1994 yes, I was planning to create an RFC and in fact I did not intend to create this PR. I wanted to first create it in my fork but it seems that somehow I made a mistake and created it here. Now that it is created I'll leave it here. |
4181b66 to
fd8f3dc
Compare
|
The parameter order should be (in my opinion)
Arguments for
|
# Conflicts: # ext/standard/basic_functions_arginfo.h
b9e8c52 to
e004c00
Compare
|
@carlos-granados What's the benefit of having these functions in the core instead of userspace? Execution speed? |
@thg2k you'll get a small performance increase but the main benefits are:
All of this in functions which are available in the core, without having to define them or import them in every project. You could ask the same about the str_starts_with, str_ends_with and str_contains functions. The same reasons to define them in the core intead of user space apply here You can read more about this in the RFC: |
|
Closing as the RFC was declined |
Adds 6 new functions which can be used to work with string suffixes and prefixes:
Add a prefix or suffix to a string only if the string does not yet have it
Remove a prefix or suffix from a string if the string has it
Replace a prefix or suffix in a string if the string has it