PHP按字符串长度标记字符串 [英] PHP Tokenize a String by its length
问题描述
嗨网络大师,
只是想知道你是否可以帮助我们想出一些令牌化的
脚本。
我的问题是想把一个很长的内容显示成一个短的段落(通过
给出最小的字母长度)
我的意思是如果我有一个2页内容 - 只是我想只显示4行
有200个字母,然后在内容后跟.....在结束时
简短的pera。
在这方面可以有人帮忙吗,
提前谢谢
Hi Web Masters,
Just wondering wether you can help us to come up with some tokenize
script.
My problem is wanted to display a LONG content into a short para (by
giving minimum letter lenght)
I mean if I have a 2 page content - just I want to display only 4 lines
having 200 letters then follows the content with "....." at the end of
short pera.
Can anybody help in this regards,
Thanks in advance
推荐答案
消息ID:< 11 ********************* @ g49g2000cwa .googlegroups。 COM>来自
Mavenos包含以下内容:
Message-ID: <11*********************@g49g2000cwa.googlegroups. com> from
Mavenos contained the following:
我的意思是如果我有2页内容 - 只是我想只显示4行
有200然后,字母跟随.....的内容。在短篇小说结束时。
任何人都可以在这方面提供帮助,
提前致谢
I mean if I have a 2 page content - just I want to display only 4 lines
having 200 letters then follows the content with "....." at the end of
short pera.
Can anybody help in this regards,
Thanks in advance
我写了这个函数来做到这一点。它有一个额外的功能,就是它在空格而不是单词的中间截断。
I wrote this function to do just that. It has the added feature that it
truncates on a space rather than the middle of the word.
字符串是长的截断的字符串
string is the long string to truncate
长度是最大截断长度
length is the maximum truncated length
这篇关于PHP按字符串长度标记字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!