Substitui toda ocorrência de determinada string por uma outra definida.

@param       string $s
String original.

@param       string $o
String que será substituída.

@param       string $n
String que será adicionada no lugar de $o.

@return      string
979462
public static function replaceAll(string $s, string $o, string $n) : string
    {
        $allPos = mb_stripos_all($s, $o);
        if (count($allPos) > 0) {
            $allPos = array_reverse($allPos);

            foreach ($allPos as $p) {
                $s = mb_substr_replace($s, $n, $p, mb_strlen($o));
            }
        }

        return $s;
    }
928125
protected static function binarySubstr($s, $p, $len = null)
    {
        if ($len === null) {
            $ret = substr($s, $p);
        } else {
            $ret = substr($s, $p, $len);
        }

        if ($ret === false) {
            $ret = '';
        }

        return $ret;
    }
146920
private function quoteApplicationName($s)
    {
        $quotedString = preg_replace('/ {2,}|\s/', ' ', $s);
        $quotedString = preg_replace('/\\\\/', '\\\\\\\\', $quotedString);
        $quotedString = preg_replace('/\//', '\\/', $quotedString);
        return $quotedString;
    }
437352
public function readExact($n)
    {
        if ($n === 0) {
            return '';
        }
        if (!$this->bev || $this->bev->input->length < $n) {
            return false;
        }
        return $this->read($n);
    }
334810
@Nullable
    public String get(int n) {
        if (capitalword_) return null;
        int len = grams_.length(); 
        if (n < 1 || n > N_GRAM || len < n) return null;
        if (n == 1) {
            char ch = grams_.charAt(len - 1);
            if (ch == ' ') return null;
            return Character.toString(ch);
        } else {
            return grams_.substring(len - n, len);
        }
    }
902940
private function calcularDvNossoNumero($nossoNumero)
    {
        $produto = 2;
        $soma = 0;

        //Separação dos números
        for ($i = 0; $i < strlen($nossoNumero); $i++) {
            //Isolando cada número
            $digito = substr(strrev($nossoNumero), $i, 1);

            //Efetuando a multiplicação do dígito isolado pelo produto
            $soma += (int) $digito * $produto;
            $produto++;
            //Se o valor do produto for maior que 9
            //O produto tem seu valor resetado, ou seja, volta para 2
            $produto = $produto > 9 ? 2 : $produto;
        }

        //Retorna o valor arredondado do resto da soma dividida por 11
        $resto = round(($soma % 11));
        $dv = 0 == $resto || 1 == $resto ? 0 : round(11 - $resto);

        return $dv;
    }
301501
public static function substr_replace($string, $replacement, $start , $length=null )
    {
        $ret = '';
        if($start>0) $ret .= self::substr($string, 0, $start);
        $ret .= $replacement;
        if($length!=null) $ret .= self::substr($string, $start+$length);
        return $ret;
    }
1304067
private function quoteApplicationName($s) {
	    $quotedString = $this->collapseWhitespace($s);
	    $quotedString = preg_replace('/\\\\/', '\\\\\\\\', $quotedString);
	    $quotedString = preg_replace('/\//', '\\/', $quotedString);
	
	    return $quotedString;
    }
41446
public static function underdashToCamel($s)
	{
		$s = strtolower($s);
		$s = preg_replace('#_(?=[a-z])#', ' ', $s);
		$s = substr(ucwords('x' . $s), 1);
		$s = str_replace(' ', '', $s);

		return $s;
	}
1239999
private function _readOfficeArtRGFOPTE($data, $n) {

		$splicedComplexData = substr($data, 6 * $n);

		// loop through property-value pairs
		for ($i = 0; $i < $n; ++$i) {
			// read 6 bytes at a time
			$fopte = substr($data, 6 * $i, 6);

			// offset: 0; size: 2; opid
			$opid = PHPExcel_Reader_Excel5::_GetInt2d($fopte, 0);

			// bit: 0-13; mask: 0x3FFF; opid.opid
			$opidOpid = (0x3FFF & $opid) >> 0;

			// bit: 14; mask 0x4000; 1 = value in op field is BLIP identifier
			$opidFBid = (0x4000 & $opid) >> 14;

			// bit: 15; mask 0x8000; 1 = this is a complex property, op field specifies size of complex data
			$opidFComplex = (0x8000 & $opid) >> 15;

			// offset: 2; size: 4; the value for this property
			$op = PHPExcel_Reader_Excel5::_GetInt4d($fopte, 2);

			if ($opidFComplex) {
				$complexData = substr($splicedComplexData, 0, $op);
				$splicedComplexData = substr($splicedComplexData, $op);

				// we store string value with complex data
				$value = $complexData;
			} else {
				// we store integer value
				$value = $op;
			}

			$this->_object->setOPT($opidOpid, $value);
		}
	}
188297
private function selectString($n)
    {
        if (is_null($this->pluralexpression)) {
            $this->pluralexpression = new ExpressionLanguage();
        }
        try {
            $plural = $this->pluralexpression->evaluate(
                $this->getPluralForms(),
                ['n' => $n]
            );
        } catch (\Exception $e) {
            $plural = 0;
        }

        if ($plural >= $this->pluralcount) {
            $plural = $this->pluralcount - 1;
        }

        return $plural;
    }
1151600
public static function replacePrefix(string $s, string $search, string $replacement = ''): string
	{
		if (strncmp($s, $search, strlen($search)) === 0) {
			$s = $replacement . substr($s, strlen($search));
		}

		return $s;
	}
692669
public static function spaceless(string $s)
	{
		$s = trim($s);
		$s = self::replace($s, '#\s#', '');

		return $s;
	}
821946
public function read($n)
    {
        if ($this->offset >= strlen($this->buffer)) {
            if (!($rv = $this->populateBuffer())) {
                return $rv;
            }
        }
        return $this->readBuffer($n);
    }
94696
public function look($n, $o = 0)
    {
        if (!isset($this->bev)) {
            return false;
        }
        if ($this->bev->input->length <= $o) {
            return '';
        }
        return $this->bev->input->substr($o, $n);
    }
265353
static function p($n) {
		$r = null;  /** @var string|null $r */
		$types = [
			self::AE => function($n) {return !!preg_match("/^3$|^3[47][0-9]{0,13}$/i", $n);}
			,self::DN => function($n) {return !!preg_match("/^3(?:0[0-5]|[68][0-9])[0-9]{4,}$/i", $n);}
			,self::DS => function($n) {return !!preg_match(
				"/^6$|^6[05]$|^601[1]?$|^65[0-9][0-9]?$|^6(?:011|5[0-9]{2})[0-9]{0,12}$/i", $n
			);}
			,self::JC => function($n) {return !!preg_match("/^(?:2131|1800|35[0-9]{3})[0-9]{3,}$/i", $n);}
			,self::MC => function($n) {return !!preg_match(
				"/^5[1-5][0-9]{5,}|222[1-9][0-9]{3,}|22[3-9][0-9]{4,}|2[3-6][0-9]{5,}|27[01][0-9]{4,}|2720[0-9]{3,}$/i", $n
			);}
			,self::VI => function($n) {return !!preg_match("/^4[0-9]{0,15}$/i", $n);}
		];
		foreach ($types as $t => $f) { /** @var string $t */
			if ($f($n)) {
				$r = $t;
				break;
			}
		}
		return $r;
	}
1233916
public function chop($n)
    {
        if ($n >= $this->size()) {
            $this->text = "";
            return;
        }

        $result = substr($this->text, 0, strlen($this->text) - $n);

        if ($result !== false) {
            $this->text = $result;
        }
    }