CoreFiles by mySites.guru
strspn.php41 lines, 973 bytes, from Joomla_1.6.4-Stable-Full_Package.zip
Raw History Compare with 1.6.3
md5
2c704d0e4444576909556d8730d3e99b
sha1
d5e67e2fe62413e104f9380b4c25ea2178a4e826
sha256
7ac5ee8821317480e12a7acf0bf2a5fbbb0aad2c51433a309307416660689a12
<?php
/**
* @version $Id: strspn.php 18212 2010-07-22 06:02:54Z eddieajau $
* @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 7 releases, Joomla 1.6.0 to 1.6.6. See them all, or every version of this file.