public static function strspn($str, $mask, $start = null, $length = null)
    {
        $mask = preg_replace('!([\\\\\\-\\]\\[/^])!', '\\\${1}', $mask);

        if ($start !== null || $length !== null) {
            $str = AnHelperString::substr($str, $start, $length);
        }

        preg_match('/^['.$mask.']+/u', $str, $matches);

        if (isset($matches[0])) {
            return AnHelperString::strlen($matches[0]);
        }

        return 0;
    }
public static function strspn($str, $mask, $start = null, $length = null)
    {
        $mask = preg_replace('!([\\\\\\-\\]\\[/^])!', '\\\${1}', $mask);

        if ($start !== null || $length !== null) {
            $str = AnHelperString::substr($str, $start, $length);
        }

        preg_match('/^['.$mask.']+/u', $str, $matches);

        if (isset($matches[0])) {
            return AnHelperString::strlen($matches[0]);
        }

        return 0;
    }
public static function strspn ( $ str , $ mask , $ start = null , $ length = null ) { $ mask = preg_replace ( '!([\\\\\\-\\]\\[/^])!' , '\\\${1}' , $ mask ) ; if ( $ start !== null || $ length !== null ) { $ str = AnHelperString :: substr ( $ str , $ start , $ length ) ; } preg_match ( '/^[' . $ mask . ']+/u' , $ str , $ matches ) ; if ( isset ( $ matches [ 0 ] ) ) { return AnHelperString :: strlen ( $ matches [ 0 ] ) ; } return 0 ; }
UTF-8 aware alternative to strspn

Find length of initial segment matching mask

@param string the haystack
@param string the mask
@param int start optional
@param int length optional
@see http://www.php.net/strspn
UTF - 8 aware alternative to strspn