PHP分页脚本
$string = "This is my page content. This text will be paginated.";
$pageNo = "0";
$pieceLength = "12";
$preparedForPrint = substr($string,$pageNo,$pieceLength);
我想要做的是,如果第 12 个字符在单词内(第 12 个字符不是空格),我想移动光标,直到找到空格并返回该子字符串,尽管事实上该子字符串长度超过 12 个字符。我怎样才能做到这一点?谢谢
$string = "This is my page content. This text will be paginated.";
$pageNo = "0";
$pieceLength = "12";
$preparedForPrint = substr($string,$pageNo,$pieceLength);
what i want to do is if the 12th character is inside a word(the 12th character is not a space) i want to move my cursor 'till it finds a space an return that substring despite the fact that is more than 12 characters long. how can i do that? thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 strpos()
http://php.net/manual/en/function。 strpos.php
You can use strpos()
http://php.net/manual/en/function.strpos.php
像这样的东西:
还要考虑 php 内置 wordwrap
something like this:
Also consider php builtin wordwrap
看看 strpos();偏移量将为
$pieceLength
,但返回的位置仍然是从干草堆的开头开始。Look at strpos(); offset would be
$pieceLength
, but position returned is still from beginning of the haystack.