PHP での文字列のインターセプトは utf-8_PHP チュートリアルをサポートしています

WBOY
リリース: 2016-07-21 15:57:41
オリジナル
792 人が閲覧しました

インターセプト文字列
$string="2006 年 4 月に 1 歳になりました!";
echo substr($string,1)."..."
//インターセプト文字列
function SubstrGB($in) ,$num)
{
$pos=0;
while($pos {
$c=substr($in,$pos, 1); ($c=="n") ブレーク;
if(ord($c)>128)
$out.=$c;
$c=substr($in ,$pos,1) );
$out.=$c;
else
{
$out.=$c;
$pos++;
return $out; }
echo SubstrGB($string,8);
?>
/*************************************************** * ***********************
* *cut_string.php
* * ----------------- - ----------
* 日付: 2005 年 7 月 16 日
* 著作権: なし
* メール:
*
* 機能: 中国語の文字をインターセプトします。 ***** ******************************************** ****** *****************/
function Cut_str($string, $sublen, $start = 0, $code = 'UTF- 8')
{
if($code == 'UTF-8')
{
$pa = "/[x01-x7f]|[xc2-xdf][x80-xbf]|xe0[ xa0-xbf][ x80-xbf]|[xe1-xef][x80-xbf][x80-xbf]|xf0[x90-xbf][x80-xbf][x80-xbf]|[xf1-xf7][x80 -xbf][x80 -xbf][x80-xbf]/";
preg_match_all($pa, $string, $t_string);
if(count($t_string[0]) - $start > $sublen) return join ('', array_slice) ($t_string[0], $start, $sublen))."..."; ('', array_slice($t_string[0], $start, $sublen))."... }
;それ以外の場合、($ i = 0; $ i< $ strlen; $ i ++)> 129)$ tmpstr($ string、$ i、2)> 129)$ i++;
;br>" .cut_str($string,8,$start=0,$code='sdf') ;
?>




http://www.bkjia.com/PHPjc/317768.html

www.bkjia.com

tru​​e

http://www.bkjia.com/PHPjc/317768.html

技術記事

Intercept string?php $string="2006 年 4 月に 1 歳になりました!"; echosubstr($string,1)."..."; //Intercept string functionSubstrGB($in,$num) { $pos=0 ; $out="" while($poststrlen($in...





ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!