public static function count($string = false, $selector = false) {

        if ($string) {

            switch ($selector) {
                case 'words':
                    return str_word_count($string);
                default:
                    if (self::substring($selector, 0, 1) === ':') {
                        return substr_count($string, self::substring($selector, 1));
                    }
                    return self::length($string);
            }
        }

        return false;
    }
public static function count($string = false, $selector = false) {

        if ($string) {

            switch ($selector) {
                case 'words':
                    return str_word_count($string);
                default:
                    if (self::substring($selector, 0, 1) === ':') {
                        return substr_count($string, self::substring($selector, 1));
                    }
                    return self::length($string);
            }
        }

        return false;
    }
public static function count ( $ string = false , $ selector = false ) { if ( $ string ) { switch ( $ selector ) { case 'words' : return str_word_count ( $ string ) ; default : if ( self :: substring ( $ selector , 0 , 1 ) === ':' ) { return substr_count ( $ string , self :: substring ( $ selector , 1 ) ) ; } return self :: length ( $ string ) ; } } return false ; }
Get string length, number of words or the occurences of specific word.
@param string full string
@param string selector
@example count('hello world') - will return length of string which is 11
@example count('hello world', 'words') - will return number of words which is 2
@example count('hello world', ':hello') - will return number of occurences of string 'hello' which is 1
@return boolean
Get string length number of words or the occurences of specific word .