Example #1
0
 /**
  * UTF-8 aware alternative to strspn
  * Find length of initial segment matching mask
  *
  * @param   string   $str     The haystack
  * @param   string   $mask    The mask
  * @param   integer  $start   Start optional
  * @param   integer  $length  Length optional
  *
  * @return  integer
  *
  * @see     http://www.php.net/strspn
  * @since   11.1
  */
 public static function strspn($str, $mask, $start = null, $length = null)
 {
     jimport('phputf8.strspn');
     if ($start === null && $length === null) {
         return utf8_strspn($str, $mask);
     } elseif ($length === null) {
         return utf8_strspn($str, $mask, $start);
     } else {
         return utf8_strspn($str, $mask, $start, $length);
     }
 }
Example #2
0
 /**
  * UTF-8 aware alternative to strspn
  * Find length of initial segment matching mask
  *
  * @static
  * @access public
  * @param string the haystack
  * @param string the mask
  * @param int start optional
  * @param int length optional
  * @see http://www.php.net/strspn
  */
 public static function strspn($str, $mask, $start = NULL, $length = NULL)
 {
     jimport('phputf8.strspn');
     if ($start === FALSE && $length === FALSE) {
         return utf8_strspn($str, $mask);
     } else {
         if ($length === FALSE) {
             return utf8_strspn($str, $mask, $start);
         } else {
             return utf8_strspn($str, $mask, $start, $length);
         }
     }
 }
 /**
  * UTF-8 aware alternative to strspn
  * Find length of initial segment matching mask
  *
  * @param   string   $str     The haystack
  * @param   string   $mask    The mask
  * @param   integer  $start   Start optional
  * @param   integer  $length  Length optional
  *
  * @return  integer
  *
  * @see     http://www.php.net/strspn
  * @since   2.0
  */
 public static function strspn($str, $mask, $start = null, $length = null)
 {
     if (!function_exists('utf8_strspn')) {
         require_once __DIR__ . '/phputf8/strspn.php';
     }
     if ($start === null && $length === null) {
         return utf8_strspn($str, $mask);
     }
     if ($length === null) {
         return utf8_strspn($str, $mask, $start);
     }
     return utf8_strspn($str, $mask, $start, $length);
 }
Example #4
0
 /**
  * UTF-8 aware alternative to strspn
  * Find length of initial segment matching mask
  *
  * @param   string   $str     The haystack
  * @param   string   $mask    The mask
  * @param   integer  $start   Start optional
  * @param   integer  $length  Length optional
  *
  * @return  integer
  *
  * @see     http://www.php.net/strspn
  * @since   1.0
  */
 public static function strspn($str, $mask, $start = null, $length = null)
 {
     require_once __DIR__ . '/phputf8/strspn.php';
     if ($start === null && $length === null) {
         return utf8_strspn($str, $mask);
     } elseif ($length === null) {
         return utf8_strspn($str, $mask, $start);
     } else {
         return utf8_strspn($str, $mask, $start, $length);
     }
 }
 /**
  * UTF-8 aware alternative to strspn()
  *
  * Find length of initial segment matching mask.
  *
  * @param   string   $str     The haystack
  * @param   string   $mask    The mask
  * @param   integer  $start   Start optional
  * @param   integer  $length  Length optional
  *
  * @return  integer
  *
  * @see     http://www.php.net/strspn
  * @since   1.3.0
  */
 public static function strspn($str, $mask, $start = null, $length = null)
 {
     if ($start === null && $length === null) {
         return utf8_strspn($str, $mask);
     }
     if ($length === null) {
         return utf8_strspn($str, $mask, $start);
     }
     return utf8_strspn($str, $mask, $start, $length);
 }
Example #6
0
 function testLinefeedMask()
 {
     $str = "iñtërnât\niônàlizætiøn";
     $this->assertEqual(utf8_strspn($str, "âëiônñrt\n"), 12);
 }