1 求长度,最基本的 $text = "sunny day";
$count = strlen($text); // $count = 9
2 字符串截取
截取前多少个字符
$article = "breaking news: in ultimate irony, man bites dog."; $summary = substr_replace($article, "...", 40);
3 算单词数 $article = "breaking news: in ultimate irony, man bites dog."; $wordcount = str_word_count($article);
// $wordcount = 8
4 将字符串变成html的连接
$url = "w.j. gilmore, llc (//www.jb51.net)";
$url = preg_replace("/http://([a-z0-9./-]+)/", "$0", $url);
5 去除字符中的html字符串
$text = strip_tags($input, "
");
6 nl2br:
$comment = nl2br($comment);
变成带html格式
7 wordwrap
限制每行字数
$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);
输出:
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.
如对本文有疑问,
点击进行留言回复!!
相关文章:
-
-
-
网安追踪流程
1.不用代理网民发帖流程:发帖人 → ISP → 服务器托管商 → 服务器网警追踪流程:网监 → 服务器IP →...
[阅读全文]
-
-
-
HTTP状态码大全
转自:https://www.cnblogs.com/lxinxuan/archive/2009/10/22/1...
[阅读全文]
-
-
-
-
-
网友评论