PHP RFC: Implement strrstr counterpart to strstr for consistency
- Version: 0.9
- Date: 2019-06-20
- Author: George Peter Banyard girgias@php.net
- Status: Withdrawn (2019-07-03)
- First Published at: http://wiki.php.net/rfc/implement-strrstr-for-consistency
Introduction
Implement strrstr (and possibly strristr) for consistency with the strpos string functions family.
Currently there exist no “proper” counter part to the strstr (and stristr) standard string function.
There exist strrchr however it does not have the same signature as strstr nor strchr as strchr is an alias of strstr, nor does it provide the same features.
Proposal
Implement strrstr and strristr (?) in PHP 7.4 with the same features as strstr, meaning that the $needle parameter can accept multiple characters and add a boolean parameter $before_needle which has a default value of false.
Pros
- Consistency within the standard library
- Feature built-in to the language
Cons
- More “bloat” in the global namespace
- Follows an old naming scheme
- Adds a function alias to the language
- Easily implemented in userland
Backward Incompatible Changes
None
Proposed PHP Version(s)
Next minor i.e. PHP 7.4.
Open Issues
How to handle the newly created alias.
Proposed Voting Choices
2/3 Majority for adding strrstr (and possibly strristr after discussion).
Patches and Tests
GitHub PR #4064
Implementation
After the project is implemented, this section should contain
- the version(s) it was merged into
- a link to the git commit(s)
- a link to the PHP manual entry for the feature
- a link to the language specification section (if any)
References
Announcement on internals: https://externals.io/message/105997