Php digest generation function (no garbled code ). When using the strip_tags () command, you must add strip_tags () to the function. The following figure shows the strip_tags () content of the Digest to be generated. of course, you can add strip_tags () directly to the function, add it by yourself. The following are functions:
The code is as follows:
Function cutstr ($ string, $ length, $ charset, $ dot) {// character, truncation length, character set, and TerminatorIf (strlen ($ string) Retu
The following describes how to use php to intercept a specified length. For more information about how to use PHP to intercept a string, see the php language.
The code is as follows:
Function cutstr ($ string, $ length, $ dot = '...'){
If (strlen ($ string) Return $ string;
}
$ Pre = chr (1 );
$ End = chr (1 );
$ String = str_replace (array ('', '"', '
$ Strcut = '';
If (strtolower (CHARSET) = 'utf-8 '){
$ N = $ tn = $ noc = 0;
While ($ n
$ T = ord
Today, I encountered a problem of intercepting Chinese and English strings. in gbk, each word occupies two bytes in Chinese. if it is all Chinese, use the substr () function, however, if both Chinese and English are available, it will be troublesome. I found a good function in the previous code, which is a good implementation.
The code is as follows:
Function get_word ($ string, $ length, $ dot = '..', $ charset = 'gbk '){
If (strlen ($ string) Return $ string;
}
$ String = str_replace (array (
Here we provide an intercept function that supports mixing Chinese characters with English characters, including html tags. Let's take a look at this function. Here we provide an intercept function that supports mixing Chinese characters with English characters, including html tags. Let's take a look at this function.
Script ec (2); script
Chinese and English string truncation functions (including html)
Function get_word ($ string, $ length, $ dot = '..', $ charset = 'gbk '){If (strlen ($
When using the strip_tags () command, you must add strip_tags () to the function. The following are functions:Copy codeThe Code is as follows:Function cutstr ($ string, $ length, $ charset, $ dot) {// character, truncation length, Character Set, and TerminatorIf (strlen ($ string) Return $ string;}$ Pre = chr (1 );$ End = chr (1 );// Protect Special strings$ String = str_replace (array ('', '"', '$ Strcut = '';If (strtolower ($ charset) = 'utf-8 '){$ N = $ tn = $
The following describes how to use php to intercept a specified length.
The following describes how to use php to intercept a specified length.
PHP language: Cut strings based on Chinese Characters
The Code is as follows:
Function cutstr ($ string, $ length, $ dot = '...'){If (strlen ($ string) Return $ string;}$ Pre = chr (1 );$ End = chr (1 );$ String = str_replace (array ('', '"', '$ Strcut = '';If (strtolower (CHARSET) = 'utf-8 '){$ N = $ tn = $ no
Today, I encountered a problem of intercepting Chinese and English strings. in gbk, each word occupies two bytes in Chinese. if it is all Chinese, use the substr () function, however, if both Chinese and English are available, it will be troublesome. I found a good function in the previous code, which is a good implementation.
Copy codeThe code is as follows:
Function get_word ($ string, $ length, $ dot = '..', $ charset = 'gbk '){
If (strlen ($ string) Return $ string;
}
$ String = str_replace
PHPsubistr truncated string without code
Time UPDATED: 20120102
/**
* [WebodMin] (C) 2010-2099 Blank Inc.
* This is NOT a freeware, use is subject to license terms
*
**/
Function subistr ($ string, $ length, $ dot = '...'){
Global $ charset;
If (strlen ($ string)
Return $ string;
}
$ S = '';
If (strtolower ($ charset) = 'utf-8 '){
$ N = $ tn = $ noc = 0
The Chinese and English string truncation function (including html) in php is provided here to support the intercept of Chinese characters and English characters, including html tags, let's take a look at this screenshot function.
The sample code is as follows:
Function get_word ($ string, $ length, $ dot = '..', $ charset = 'gbk '){
If (strlen ($ string)
Return $ string;
}
$ String = str_replace (array ('','', '', '"', '
$ Strcut = '';
If (strtolower ($ charset) = 'utf-8 '){
$ N = $ tn = $
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.