Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/238.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP分页脚本_Php_Pagination_Substr - Fatal编程技术网

PHP分页脚本

PHP分页脚本,php,pagination,substr,Php,Pagination,Substr,我想做的是,如果第12个字符在一个单词内(第12个字符不是空格),我想移动光标,直到它找到一个空格,返回该子字符串,尽管它的长度超过12个字符。我该怎么做?谢谢诸如此类的东西: $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);

也考虑PHP BuiTuin

这样的事情:

$string = "This is my page content. This text will be paginated.";
$pageNo = "0";
$pieceLength = "12";  

$preparedForPrint = substr($string,$pageNo,$pieceLength);

也考虑PHP BuiTuin

< P>偏移量应该是
$piecenegth
,但返回的位置仍然是从草堆的开始;偏移量将是
$piecenegth
,但返回的位置仍然是从干草堆开始的位置。

您可以使用strpos()

您可以使用strpos()

$pieceLength = strpos($string," ",12);