Home > Backend Development > PHP Tutorial > PHP Chinese character interception function_PHP tutorial

PHP Chinese character interception function_PHP tutorial

WBOY
Release: 2016-07-15 13:22:09
Original
1253 people have browsed it

Chinese character interception function
//The string to be intercepted, $num the length to be intercepted, return the intercepted string

public function substrgb($in,$num)
    {
      //$num=16;
      $pos=0;
      $bytenum=0;
      $out="";
      while($num){
    
    $c=mb_substr($in,$pos,1,"euc-jp");
    if($c=="n") break;
    if(strlen($c)==1){
      $pos++;
      $bytenum++;
      if($bytenum>$num) break;
      $out.=$c;                        
    }
    else
      {
        $pos++;
        $bytenum=$bytenum+2;
        if($bytenum>$num) break;
        $out.=$c;                   
      }
      }
      return $out;
    }
Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/447005.htmlTechArticleChinese character interception function //String to be intercepted, $num length to be intercepted, return the intercepted string public function substrgb($in,$num) { //$num=16; $pos=0; $bytenum=0; $out=; while(...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template