One night, a woman is going to set you up. txt PHP collection book and synthesis TXT format implementation code

Source: Internet
Author: User
/**
* @name collection book. php
* @date Sun Mar 22:48:02 CST 2009
* @copyright Ma Yongjin (Myz)
* @author Ma Yongjin (Myz)
* @link http://blog.csdn.net/mayongzhan/
*/
Header (' Content-type:text/html;charset=utf8 ');
Header (' content-type:text/html;charset=gb2312 ');
Error_reporting (E_all);
Date_default_timezone_set (' Asia/shanghai ');
Set_time_limit (0);
function writer ($content, $url)
{
$fp = fopen ($url, ' ab ');
Fwrite ($fp, $content);
Fclose ($FP);
}
$folder = ' 2 '; Folder
$book _base_url = ' xxxxxxxxxxxxxxxxxxxxx ';
$book _url = ' yyyyyyyyyyyyy.html ';
$main = file_get_contents ($book _base_url. $book _url);
Preg_match_all ('/chapter_.*?\.html/', $main, $pages);
$pages = Array_unique ($pages [0]);
foreach ($pages as $value) {
Writer (file_get_contents ($book _base_url $value), './'. $folder. ' /'. $value. '. TXT ');
$str = file_get_contents ('./'. $folder. ' /'. $value. '. TXT ');
Print_r ($STR);
Preg_match ("/(

) (. *?) (<\/h1>) (.*?) ()(.*?) (<\/div>)/S ", $str, $arr);
//print_r ($arr);d ie ();
$arr [6] = Preg_replace ("/( ]+>.*?) +>) (. *?) (<\/a><\/span>)/S "," $ ", preg_replace ("/

|<\/p>/"," \ r \ n ", $arr [6]));
$result = "\ r \ n------------------------------------------------\r\ n------------------------------------------------\ r \------------------------------------------------\r\ N----------------". $arr [2]." \ r \ n------------------------------------------------\ r \------------------------------------------------\r\ n------------------------------------------------\ r \ nyou '. $arr [6];
Writer ($result, './'. $folder. ' /new.txt ');
}
?>

Above describes a night of the woman to set you txt PHP collection book and the implementation of the TXT format code, including a night of the woman to set your TXT content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.