php對文字檔進行分頁功能簡單實現,_PHP教程

來源:互聯網
上載者:User

php對文字檔進行分頁功能簡單實現,


php對文字檔進行分頁功能簡單實現

        Paging    php// 中文字元處理function m_substr($str, $start, $length){    $str_length = $start + $length; // 擷取截取總長度    $tmp_str = "";    for($i=0;$i<$str_length;$i++){        if(ord(substr($str, $i, 1)) == 0x0a){            $tmp_str .= "
"; } if(ord(substr($str, $i, 1))>0xa0){ $tmp_str .= substr($str, $i, 2); $i++; }else{ $tmp_str .= substr($str, $i, 1); } } return $tmp_str;}// 傳參處理if(isset($_GET['page'])){ $page = $_GET['page'];}else{ $page = 1;}$counter = file_get_contents("example.txt");$length = strlen($counter);$page_count = ceil($length/400);$pre_str = m_substr($counter, 0, ($page-1)*400);$now_str = m_substr($counter, 0, $page*400);echo substr($now_str, strlen($pre_str), strlen($now_str)-strlen($pre_str));echo "

";echo "當前頁".$page."/".$page_count;echo "Index";if($page>1){ echo "$page-1)."'>Pre";}if($page<$page_count){ echo "$page+1).">Next";}echo "$page_count>End";?>

http://www.bkjia.com/PHPjc/1053804.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1053804.htmlTechArticlephp對文字檔進行分頁功能簡單實現, php對文字檔進行分頁功能簡單實現 !DOCTYPEhtmlhead meta http-equiv="Content-type" content="text/html";charset="gb...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.