


How to use the lookup function PHP long article paging function with usage instructions, paragraphs will not be divided, pages will be turned at the bottom
Copy code The code is as follows:
{
global $expert_id;
$PageLength = 2000; //Number of words per page
$CLength = strlen( $content);
$PageCount = floor(($CLength / $PageLength)) + 1; //Calculate the number of pages
$PageArray=array();
$Seperator = array("n","r",". ","! ","? ",";",",",""","'"); //delimiter
//echo "Page count:".$PageCount."
" ;
//echo "Length: ".$CLength."
";
//strpos() function returns the position of the first occurrence of a string in another string
if($CLength<$PageLength)
{
echo $content;
}else{
$PageArray[0]=0;
$Pos = 0;
$i=0;
//First page
for( $j=0;$j
//echo $Seperator[$j];
$Pos=strpos($content,$Seperator[$j],$PageArray[$ i]+1900);
while($Pos > 0 && $Pos < ($i+1)*$PageLength && $Pos > $i*$PageLength )
{
$PageArray[$i] = $ Pos ;
$Pos = strpos($Pos+$PageLength,$content,$Seperator[$j]) ;
}
if($PageArray[$i]>0)
{
$j = $j + sizeof( $Seperator) + 1;
}
}
//---
for($i=1;$i<$PageCount-1;$i++){
for($j=0;$j
//echo $Seperator[$j];
$Pos=strpos($content,$Seperator[$j],$PageArray[$i-1]+1900);
while( $Pos > 0 && $Pos < ($i+1)*$PageLength && $Pos > $i*$PageLength )
{
$PageArray[$i] = $Pos ;
$Pos = strpos($ Pos+$PageLength,$content,$Seperator[$j]) ;
}
if($PageArray[$i]>0)
{
$j = $j + sizeof($Seperator) + 1;
}
}
}
//--Last page
$PageArray[$PageCount-1]=$CLength;
//$page=2;
if($page==1)
{
$output=substr($ content,0,$PageArray[$page-1]+2);
}
if($page>1 && $page<=$PageCount)
{
$output=substr($content,$PageArray[$page- 2]+2,$PageArray[$page-1]-$PageArray[$page-2]);
$output=" (continued from page ".($page-1).")n".$output ;
}
echo str_replace("n","
",$output);
//if($page==$PageCount)
//return $output=substr($content,$PageArray[$ page-2]+2,$PageArray[$page-1]-$PageArray[$page-2]);
if($PageCount>1)
{
echo "
";
echo "".$page."/".$PageCount." page ";
if($page>1)
echo "Previous page ";
else
echo "Previous page";
for( $i=1;$i<=$PageCount;$i++)
{
echo "[".$i."]< ;/a> ";
}
if($page<$PageCount)
echo " Next page< /a> ";
else
echo " next page";
echo "";
}
}
}?>
Use
to copy the code The code is as follows:
$c
$current=$_REQUEST['page_t'];
$result=ff_page($content1,$current);
echo $result;
?>
The above introduces how to use the lookup function. The PHP long article paging function comes with how to use it. It does not divide paragraphs, and the page is turned at the bottom. It includes how to use the lookup function. I hope it will be helpful to friends who are interested in PHP tutorials. .

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.
