PHP代码:
-
<?php
-
function c_substr($string, $from, $length = null){
-
}else{
-
}
-
return $result;
-
}
-
$str = "zhon华人min共和guo";
-
$from = 3;
-
$length = 7;
-
// 输出: n华人min共
-
//还有utf-8的
-
/*
-
Regarding windix's function to handle UTF-8 strings:
-
one can use the "u" modifier on the regular expression so that the pattern string is treated as UTF-8
-
(available from PHP 4.1.0 or greater on Unix and from PHP 4.2.3 on win32).
-
This way the function works for other encodings too (like Greek for example).
-
The modified function would read like this:
-
*/
-
function utf8_substr($str,$start) {
-
$null = "";
-
} else {
-
}
-
}
-
?>