php生成文件 php
这是一个原html文件nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">无标题文档
nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">无标题文档
$s =得到无标题文档 HTML;preg_match_all('/.*?/is', $s, $r);print_r($r[0]);
Array( [0] => nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">无标题文档 [1] =>[2] => )
$fn = array('head.html', ' index.html', 'foot.html');foreach($r[0] as $i=>$s) file_put_contents($fn[$i], $s);
$s =无标题文档 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];
nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">无标题文档
已抢65566个
抢已抢30249个
抢已抢16626个
抢已抢8440个
抢已抢10922个
抢已抢22287个
抢