This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Replace all occurrences of the search string with the replacement string. | |
* @param {array|string} search The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles. | |
* @param {array|string} replace The replacement value that replaces found search values. An array may be used to designate multiple replacements. | |
* @param {array|string} subject The string or array being searched and replaced on, otherwise known as the haystack. If subject is an array, then the search and replace is performed with every entry of subject, and the return value is an array as well. | |
* @param {object|null} count If passed, this will be set to the number of replacements performed. | |
* @returns {array|string} This function returns a string or an array with the replaced values. | |
*/ | |
function str_replace(search, replace, subject, count = null) { | |
if ('' === subject) return '' |