CoreFiles by mySites.guru
strspn.php41 lines, 923 bytes, from Joomla_2.5.21-Stable-Full_Package.zip
Raw History Compare with 2.5.20
md5
f049c800e21a400c5a97fb8fb7eb7005
sha1
348374e02e6d28fa5e9b197856f476b46cb8c1df
sha256
eff25a9eb0fb305f08649724c6b39c5dc353d8c24f193a2d8fcebedd3ef869bd
<?php
/**
* @version $Id$
* @package utf8
* @subpackage strings
*/

//---------------------------------------------------------------
/**
* UTF-8 aware alternative to strspn
* Find length of initial segment matching mask
* Note: requires utf8_strlen and utf8_substr (if start, length are used)
* @param string
* @return int
* @see http://www.php.net/strspn
* @package utf8
* @subpackage strings
*/
function utf8_strspn($str, $mask, $start = NULL, $length = NULL) {

    $mask = preg_replace('!([\\\\\\-\\]\\[/^])!','\\\${1}',$mask);

	// Fix for $start but no $length argument.
    if ($start !== null && $length === null) {
    	$length = utf8_strlen($str);
    }

    if ( $start !== NULL || $length !== NULL ) {
        $str = utf8_substr($str, $start, $length);
    }

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

    if ( isset($matches[0]) ) {
        return utf8_strlen($matches[0]);
    }

    return 0;

}

The same content is in 87 releases, Joomla 1.7.0 to 3.5.1. See them all, or every version of this file.