Stringy\Stringy::countSubstr PHP Méthode

countSubstr() public méthode

By default, the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.
public countSubstr ( string $substring, boolean $caseSensitive = true ) : integer
$substring string The substring to search for
$caseSensitive boolean Whether or not to enforce case-sensitivity
Résultat integer The number of $substring occurrences
    public function countSubstr($substring, $caseSensitive = true)
    {
        if ($caseSensitive) {
            return \mb_substr_count($this->str, $substring, $this->encoding);
        }
        $str = \mb_strtoupper($this->str, $this->encoding);
        $substring = \mb_strtoupper($substring, $this->encoding);
        return \mb_substr_count($str, $substring, $this->encoding);
    }