php對(duì)文本文件開(kāi)展分頁(yè)功能簡(jiǎn)單實(shí)現(xiàn)
Jun 13, 2016 pm 12:24 PM
php對(duì)文本文件進(jìn)行分頁(yè)功能簡(jiǎn)單實(shí)現(xiàn)
php對(duì)文本文件進(jìn)行分頁(yè)功能簡(jiǎn)單實(shí)現(xiàn)
<meta http-equiv="Content-type" content="text/html"> <title>Paging</title> <style><span style="color: #000000;"> a{ padding:<span style="color: #000000;">20px; } </style><span style="color: #000000;">php</span><span style="color: #008000;">//</span><span style="color: #008000;"> 中文字符處理</span><span style="color: #0000ff;">function</span> m_substr(<span style="color: #800080;">$str</span>, <span style="color: #800080;">$start</span>, <span style="color: #800080;">$length</span><span style="color: #000000;">){ </span><span style="color: #800080;">$str_length</span> = <span style="color: #800080;">$start</span> + <span style="color: #800080;">$length</span>; <span style="color: #008000;">//</span><span style="color: #008000;"> 獲取截取總長(zhǎng)度</span> <span style="color: #800080;">$tmp_str</span> = ""<span style="color: #000000;">; </span><span style="color: #0000ff;">for</span>(<span style="color: #800080;">$i</span>=0;<span style="color: #800080;">$i</span>$str_length;<span style="color: #800080;">$i</span>++<span style="color: #000000;">){ </span><span style="color: #0000ff;">if</span>(<span style="color: #008080;">ord</span>(<span style="color: #008080;">substr</span>(<span style="color: #800080;">$str</span>, <span style="color: #800080;">$i</span>, 1)) == 0x0a<span style="color: #000000;">){ </span><span style="color: #800080;">$tmp_str</span> .= "<br>"<span style="color: #000000;">; } </span><span style="color: #0000ff;">if</span>(<span style="color: #008080;">ord</span>(<span style="color: #008080;">substr</span>(<span style="color: #800080;">$str</span>, <span style="color: #800080;">$i</span>, 1))>0xa0<span style="color: #000000;">){ </span><span style="color: #800080;">$tmp_str</span> .= <span style="color: #008080;">substr</span>(<span style="color: #800080;">$str</span>, <span style="color: #800080;">$i</span>, 2<span style="color: #000000;">); </span><span style="color: #800080;">$i</span>++<span style="color: #000000;">; }</span><span style="color: #0000ff;">else</span><span style="color: #000000;">{ </span><span style="color: #800080;">$tmp_str</span> .= <span style="color: #008080;">substr</span>(<span style="color: #800080;">$str</span>, <span style="color: #800080;">$i</span>, 1<span style="color: #000000;">); } } </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$tmp_str</span><span style="color: #000000;">;}</span><span style="color: #008000;">//</span><span style="color: #008000;"> 傳參處理</span><span style="color: #0000ff;">if</span>(<span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_GET</span>['page'<span style="color: #000000;">])){ </span><span style="color: #800080;">$page</span> = <span style="color: #800080;">$_GET</span>['page'<span style="color: #000000;">];}</span><span style="color: #0000ff;">else</span><span style="color: #000000;">{ </span><span style="color: #800080;">$page</span> = 1<span style="color: #000000;">;}</span><span style="color: #800080;">$counter</span> = <span style="color: #008080;">file_get_contents</span>("example.txt"<span style="color: #000000;">);</span><span style="color: #800080;">$length</span> = <span style="color: #008080;">strlen</span>(<span style="color: #800080;">$counter</span><span style="color: #000000;">);</span><span style="color: #800080;">$page_count</span> = <span style="color: #008080;">ceil</span>(<span style="color: #800080;">$length</span>/400<span style="color: #000000;">);</span><span style="color: #800080;">$pre_str</span> = m_substr(<span style="color: #800080;">$counter</span>, 0, (<span style="color: #800080;">$page</span>-1)*400<span style="color: #000000;">);</span><span style="color: #800080;">$now_str</span> = m_substr(<span style="color: #800080;">$counter</span>, 0, <span style="color: #800080;">$page</span>*400<span style="color: #000000;">);</span><span style="color: #0000ff;">echo</span> <span style="color: #008080;">substr</span>(<span style="color: #800080;">$now_str</span>, <span style="color: #008080;">strlen</span>(<span style="color: #800080;">$pre_str</span>), <span style="color: #008080;">strlen</span>(<span style="color: #800080;">$now_str</span>)-<span style="color: #008080;">strlen</span>(<span style="color: #800080;">$pre_str</span><span style="color: #000000;">));</span><span style="color: #0000ff;">echo</span> "<br><br>"<span style="color: #000000;">;</span><span style="color: #0000ff;">echo</span> "當(dāng)前頁(yè)".<span style="color: #800080;">$page</span>."/".<span style="color: #800080;">$page_count</span><span style="color: #000000;">;</span><span style="color: #0000ff;">echo</span> "<a href="index.php?page=1">Index</a>"<span style="color: #000000;">;</span><span style="color: #0000ff;">if</span>(<span style="color: #800080;">$page</span>>1<span style="color: #000000;">){ </span><span style="color: #0000ff;">echo</span> "<a href="index.php?page=%22.(<span%20style=%22color:%20#800080;%22>%24page</span>-1).%22">Pre</a>"<span style="color: #000000;">;}</span><span style="color: #0000ff;">if</span>(<span style="color: #800080;">$page</span>$page_count<span style="color: #000000;">){ </span><span style="color: #0000ff;">echo</span> "<a href="index.php?page=%22.(<span" style="color: #800080;">$page+1).">Next</a>"<span style="color: #000000;">;}</span><span style="color: #0000ff;">echo</span> "<a href="index.php?page=<span" style="color: #800080;">$page_count>End</a>"<span style="color: #000000;">;</span>?>

Hot AI Tools

Undress AI Tool
Undress images for free

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

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

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

Implementing data paging and display optimization in Vue projects. In Vue projects, when a page needs to display a large amount of data, data paging and display optimization usually need to be performed to improve user experience. This article will introduce how to use Vue to implement data paging and display optimization. , and provide specific code examples. 1. Data paging Data paging refers to dividing a large amount of data into multiple pages according to certain rules and displaying them on the page. You can use the following steps to implement data paging in a Vue project: Define the data source. First, define a

This article will explain in detail the ASCII value of the first character of the string returned by PHP. The editor thinks it is very practical, so I share it with you as a reference. I hope you can gain something after reading this article. PHP returns the ASCII value of the first character of a string Introduction In PHP, getting the ASCII value of the first character of a string is a common operation that involves basic knowledge of string processing and character encoding. ASCII values ??are used to represent the numeric value of characters in computer systems and are critical for character comparison, data transmission and storage. The process of getting the ASCII value of the first character of a string involves the following steps: Get String: Determine the string for which you want to get the ASCII value. It can be a variable or a string constant

This article will explain in detail how PHP returns the string from the start position to the end position of a string in another string. The editor thinks it is quite practical, so I share it with you as a reference. I hope you will finish reading this article. You can gain something from this article. Use the substr() function in PHP to extract substrings from a string. The substr() function can extract characters within a specified range from a string. The syntax is as follows: substr(string,start,length) where: string: the original string from which the substring is to be extracted. start: The index of the starting position of the substring (starting from 0). length (optional): The length of the substring. If not specified, then

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:

php提交表單通過(guò)后,彈出的對(duì)話框怎樣在當(dāng)前頁(yè)彈出php提交表單通過(guò)后,彈出的對(duì)話框怎樣在當(dāng)前頁(yè)彈出而不是在空白頁(yè)彈出?想實(shí)現(xiàn)這樣的效果:而不是空白頁(yè)彈出:------解決方案--------------------如果你的驗(yàn)證用PHP在后端,那么就用Ajax;僅供參考:HTML code

Watch4pro and gt each have different features and applicable scenarios. If you focus on comprehensive functions, high performance and stylish appearance, and are willing to bear a higher price, then Watch 4 Pro may be more suitable. If you don’t have high functional requirements and pay more attention to battery life and reasonable price, then the GT series may be more suitable. The final choice should be decided based on personal needs, budget and preferences. It is recommended to carefully consider your own needs before purchasing and refer to the reviews and comparisons of various products to make a more informed choice.
