1
0
Fork 0
php-coding/14.test6.php

24 lines
618 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
//class MsubStr
//{
// function csubstr($str, $start, $len)
// {
// $strlen = $start + $len;
// for ($i = 0; $i < $strlen; $i++) {
// if (ord(substr($str, $i, 1)) > 0xa0) {
// $tmpstr .= substr($str, $i, 2);
// $i++;
// } else {
// $tmpstr .= substr($str, $i, 1);
// }
// }
// return $tmpstr;
// }
//}
// 为什么放着mb_substr不用 非要用csubstr方法?
$string = "关注明日科技关注PHP从入门到精通改版";
$sub_string = mb_substr($string, 0, 9).'...';
echo $sub_string;