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:
$comme转念一想nt = nl2br($comment);
变成带html格式
7 wordwrap
限制每行字数
$speech = “four score and 有陪ven 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 ven years ago our fathers brought forth, upon this continent, a new nation, conceived in l高中是义务教育吗iberty, and dedicated to the proposition that all men are created equal.
本文发布于:2023-04-06 13:34:25,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/adc6103446ab996f32b0938816d228f9.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:php的字符串用法小结.doc
本文 PDF 下载地址:php的字符串用法小结.pdf
留言与评论(共有 0 条评论) |