1. Evaluate the length, the most basic
$ Text = "sunny day ";
$ Count = strlen ($ text); // $ count = 9
2 string Truncation
Number of characters before Truncation
$ Article = "breaking news: In ultimate irony, man bites dog."; $ summary = substr_replace ($ article, "...", 40 );
3 count words
$ Article = "breaking news: In ultimate irony, man bites dog."; $ wordCount = str_word_count ($ article );
// $ WordCount = 8
4. convert a string into an HTML connection
$ Url = "W. J. Gilmore, LLC (http://www.jb51.net )";
$ Url = preg_replace ("/http: // ([A-z0-9 ../-] +)/", "$0", $ url );
5 remove the HTML string from the character
$ Text = strip_tags ($ input ,"
");
6 nl2br:
$ Comment = nl2br ($ comment );
Changed to HTML Format
7 Wordwrap
Limit the number of words per line
$ Speech = "Four score and seven years ago our fathers brought forth, upon this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. ";
Echo wordwrap ($ speech, 30 );
Output:
Four score and seven years ago our fathers brought forth, upon this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.