I have also written a PHP article digest generation method (function) before, but it is not very easy to use and garbled. now I release another function, which was removed from an open-source system, if you want to use the strip_tags () command to generate a digest, add strip_tags () 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 (
In the use of the time, you have to generate a summary of the content strip_tags (), of course, you can also add strip_tags () directly into the function, I did not engage, add it myself. Here is the function:
Copy the Code code as follows:
function Cutstr ($string, $length, $charset, $dot) {//characters, intercept length, character set, end symbolif (strlen ($string) return $string;}$pre = Chr (1);$end = Chr (1);Protect Special strings$string = str_replace (Array (' ', ' ' ', ' $strcut = ";if
Cut the php code of the string function based on Chinese characters. Copy the code as follows: define (CHARSET, UTF-8 ); the default encoding is *** used to cut the string according to Chinese characters * @ param $ string-string * @ param $ length-length * @ param $ doc-shrink
The code is as follows:
Define (CHARSET, 'utf-8'); // default system encoding/*** Trim strings based on Chinese characters* @ Param $ string-string* @ Param $ length-length* @ Param $ doc-Thumbnail suffix* @ Return ret
Php: string function method based on Chinese characters. Define (CHARSET, UTF-8 ); the default encoding is *** used to cut the string according to Chinese characters * @ param $ string-string * @ param $ length-length * @ param $ doc-scaling suffix * @ return returns the character with define (CHARSET, 'utf-8'); // default system encoding
/**
* Trim strings based on Chinese characters
* @ Param $ string-string
* @ Param $ length-length
* @ Param $ doc-Thumbnail suffix
* @ Return returns the st
Here we will share with you a function that uses php to intercept strings. it is very practical and recommended to partners in need. It is often seen that some new users have asked PHP whether there is a left function or right function similar to asp, which can take N characters from the left or right of a string. Yes, of course. The substr function in PHP can be used, but PHP merges the two functions into one. here we will share with you a better function for intercepting strings.
The code is
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 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.