go to bug id or search bugs for
From manual page: https://php.net/function.str-replace
The document makes no mention of what happens if the replace array is smaller than the search array.
It appears that the search characters will be replaced with an empty string. This may or may not be expected, as the alternative result might have been to ignore the characters.
$string='apple banana cherry apple banana cherry apple banana cherry';
Add a Patch
Add a Pull Request
Sure it does.
> If replace has fewer values than search, then an empty string is used for the rest of replacement values.
Gad, you’re right. Sorry, I missed that.
It might help to include an example, though.
I suppose? It's an unusual usage of the function. In fact I'd bet that most of the time someone uses str_replace with arrays (strtr is easier) and the two arrays aren't the same size, it's a bug - or at least unintentional.
If you have a use case in mind, you can hit the Edit link in the top-right corner and submit a patch including an example. (Or amend the existing "gotchas" example.) The docs are written in XML but there should be enough there to understand how it works.