[英]PHP pagination script
$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. 我想做的是,如果第12个字符位于一个单词内(第12个字符不是空格),我想移动光标,直到找到一个空格,然后返回该子字符串,尽管事实上它的长度超过了12个字符。 how can i do that?
我怎样才能做到这一点? thanks
谢谢
You can use strpos() 您可以使用strpos()
$pieceLength = strpos($string," ",12);
http://php.net/manual/en/function.strpos.php http://php.net/manual/zh/function.strpos.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.