How does PHP process the files and extract the content generated files?

Source: Internet
Author: User
PHP Generated files php

This is an original HTML file

 
  Untitled Document






This is an HTML file that has been processed.


 
  
 
  Untitled Document
 
  
 
  







Then extract the content fragments, generate the following three files, respectively,


Extract this section to generate head.html






<title>Untitled Document</title>








Extract this section to generate index.html

















Extract this section to generate foot.html








Reply to discussion (solution)

$s =<<< HTML
 
  
 
  Untitled Document
 
    
 
  



Html;preg_match_all ('/.*? /is ', $s, $r);p rint_r ($r [0]);
Get
Array (    [0] = = 
 
  
 
  Untitled Document
 
      [1] = =   
 
  



[2] = = )

Write to File
$FN = Array (' head.html ', ' index.html ', ' foot.html '); foreach ($r [0] as $i = + $s)  file_put_contents ($fn [$i], $s);

$s =<<< HTML
 
  Untitled Document



HTML; $ar = Preg_split ("/( \s+|\r?\n\s\r?\n)/S", $s,-1, Preg_split_no_empty | preg_split_delim_capture); $d = Array (php_eol. " ," . Php_eol), foreach ($ar as $i = + $v) { if ($i) echo $d [$i%2]; echo $v;} echo $d [0];
 
  
 
  Untitled Document
 
   
 
  



  • Related Article

    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.