Heim >Backend-Entwicklung >PHP-Tutorial >PHP subistr 截取字符串无码

PHP subistr 截取字符串无码

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-25 09:08:491531Durchsuche

更新时间:20120102

  1. /**
  2. * [WebodMin] (C)2010-2099 Blank Inc.
  3. * This is NOT a freeware, use is subject to license terms
  4. *
  5. **/
  6. function subistr($string, $length, $dot = ' ...') {
  7. global $charset;
  8. if(strlen($string) return $string;
  9. }
  10. $s = '';
  11. if(strtolower($charset) == 'utf-8') {
  12. $n = $tn = $noc = 0;
  13. while($n $t = ord($string[$n]);
  14. if($t == 9 || $t == 10 || (32 $tn = 1; $n++; $noc++;
  15. } elseif(194 $tn = 2; $n += 2; $noc += 2;
  16. } elseif(224 $tn = 3; $n += 3; $noc += 2;
  17. } elseif(240 $tn = 4; $n += 4; $noc += 2;
  18. } elseif(248 $tn = 5; $n += 5; $noc += 2;
  19. } elseif($t == 252 || $t == 253) {
  20. $tn = 6; $n += 6; $noc += 2;
  21. } else {
  22. $n++;
  23. }
  24. if($noc >= $length) {
  25. break;
  26. }
  27. }
  28. if($noc > $length) {
  29. $n -= $tn;
  30. }
  31. $s = substr($string, 0, $n);
  32. } else {
  33. for($i = 0; $i $s .= ord($string[$i]) >= 127 ? $string[$i].$string[++$i] : $string[$i];
  34. }
  35. }
  36. return $s.$dot;
  37. }
复制代码


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:wecis 2.0 RC 版 Nächster Artikel:PHP 简易爬虫