protected static Memory _str_replace(Environment env, TraceInfo trace,
                                         Memory search, Memory replace, Memory string,
                                         @Reference Memory count, boolean isInsensitive) {
        if (count.isReference()) {
            count.assign(0);
        }

        if (string.isNull()) {
            return Memory.CONST_EMPTY_STRING;
        }

        if (string.isArray()) {
            ForeachIterator iterator = string.getNewIterator(env);
            ArrayMemory result = new ArrayMemory();

            while (iterator.next()) {
                Memory key = iterator.getMemoryKey();
                Memory value = iterator.getValue();

                if (value.isArray()) {
                    result.refOfIndex(key).assign(value.toImmutable());
                } else {
                    Memory ret = _str_replace(
                        env, trace, search, replace,
                        StringMemory.valueOf(value.toString()), count, isInsensitive
                    );

                    result.refOfIndex(key).assign(ret);
                }
            }

            return result.toConstant();
        } else {
            if (!search.isArray()) {
                String searchStr = search.toString();

                if (searchStr.isEmpty()) {
                    return string;
                }

                if (replace.isArray()) {
                    env.warning(trace, "str_replace(): Array to string conversion");
                }

                string = _str_replace_impl(env, trace,
                    StringMemory.valueOf(searchStr),
                    StringMemory.valueOf(replace.toString()),
                    string,
                    count,
                    isInsensitive);
            } else if (replace.isArray()) {
                ForeachIterator searchIterator = search.getNewIterator(env);
                ForeachIterator replaceIterator = replace.getNewIterator(env);

                while (searchIterator.next()) {
                    Memory searchValue = searchIterator.getValue();
                    Memory replaceValue;

                    if (replaceIterator.next()) {
                        replaceValue = replaceIterator.getValue();
                    } else {
                        replaceValue = Memory.NULL;
                    }

                    string = _str_replace(env, trace,
                        StringMemory.valueOf(searchValue.toString()),
                        StringMemory.valueOf(replaceValue.toString()),
                        string,
                        count,
                        isInsensitive);
                }
            } else {
                ForeachIterator searchIterator = search.getNewIterator(env);

                while (searchIterator.next()) {
                    string = _str_replace(
                        env, trace,
                        StringMemory.valueOf(searchIterator.getValue().toString()),
                        replace,
                        string,
                        count,
                        isInsensitive
                    );
                }
            }
        }

        return string;
    }
Parses the cslashes bitmap returning an actual bitmap.

@param charset the bitmap string

@return the actual bitmap
exts/jphp-zend-ext/src/main/java/org/develnext/jphp/zend/ext/standard/StringFunctions.java