@Immutable
    public static Memory substr_replace(Environment env, TraceInfo trace,
                                        Memory string, Memory replacementM, Memory startM, Memory lengthM) {
        int start = 0;
        int length = Integer.MAX_VALUE / 2;
        String replacement = "";

        ForeachIterator replacementIterator = null;
        if (replacementM.isArray())
            replacementIterator = replacementM.getNewIterator(env, false, false);
        else
            replacement = replacementM.toString();

        ForeachIterator startIterator = null;
        if (startM.isArray())
            startIterator = startM.getNewIterator(env, false, false);
        else
            start = startM.toInteger();

        ForeachIterator lengthIterator = null;
        if (lengthM.isArray())
            lengthIterator = lengthM.getNewIterator(env, false, false);
        else
            length = lengthM.toInteger();

        if (string.isArray()) {
            ArrayMemory resultArray = new ArrayMemory();
            ForeachIterator iterator = string.getNewIterator(env, false, false);

            while (iterator.next()) {
                String value = iterator.getValue().toString();

                if (replacementIterator != null && replacementIterator.next())
                    replacement = replacementIterator.getValue().toString();

                if (lengthIterator != null && lengthIterator.next())
                    length = lengthIterator.getValue().toInteger();

                if (startIterator != null && startIterator.next())
                    start = startIterator.getValue().toInteger();

                String result = _substr_replace(value, replacement, start, length);
                resultArray.add(new StringMemory(result));
            }

            return resultArray.toConstant();
        } else {
            if (replacementIterator != null && replacementIterator.next())
                replacement = replacementIterator.getValue().toString();

            if (lengthIterator != null && lengthIterator.next())
                length = lengthIterator.getValue().toInteger();

            if (startIterator != null && startIterator.next())
                start = startIterator.getValue().toInteger();

            return new StringMemory(_substr_replace(string.toString(), replacement, start, length));
        }
    }
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