fork(2) download
  1. <?php
  2.  
  3. $html = <<<__HTML__
  4. <html>
  5. 1111
  6. <body>
  7. <body>
  8. 内容1
  9. </body>
  10. <body>
  11. 内容2
  12. </BODY>
  13. </body>
  14. 2222
  15. </html>
  16. __HTML__;
  17.  
  18. if (preg_match('/(.*?<body>)(.*)(<\/body>.*)/si', $html, $matches)) {
  19. $prefix = $matches[1];
  20. $body = $matches[2];
  21. $suffix = $matches[3];
  22. $new_body = preg_replace('/<\/?body>\s*/i', '', $body);
  23. $html = $prefix . $new_body . $suffix;
  24. }
  25.  
  26. var_dump($html);
  27.  
Success #stdin #stdout 0.03s 52480KB
stdin
Standard input is empty
stdout
string(55) "<html>
1111
<body>
内容1
内容2
</body>
2222
</html>"