PHP根据文章标记自动切割分类为文本。
2015-11-04 17:46
731 查看
<?php
$file=<<<html
#file block/head.html
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.cxslide.min.js"></script>
<script type="text/javascript" src="js/custome.js"></script>
</head>
<body class="body_index">
<!--顶部 开始-->
<div id="top_main">
<div id="top">
<div id="top_2"><a href="" target="_blank"><span class="MobileEdition">[手机版] </span></a></div>
</div>
</div>
#file blocks/foot.html
<!--顶部 结束--><!--Logo 开始-->
<div id="logo_main">
<div id="logo"><!--网站Logo 开始-->
<div class="WebLogo"><a href="/" target="_self"><img src="images/logo.png" title="" alt="" /></a></div>
<!--网站Logo 结束--></div>
</div>
<!--Logo 结束--><!--导航条 开始-->
<div id="navigation_main">
<div id="navigation">
<ul class="navigationlist">
#file body.html
html;
//$file=file_get_contents("index.html");
$list=explode("#file",$file);
array_shift($list);
foreach($list as $key){
$outfile="";
$filename="";
$outfile=split("\r\n",$key);
$filename=trim($outfile[0]);
$path=pathinfo($filename,PATHINFO_DIRNAME);
if(!empty($path)){
if(!file_exists($path)){
mkdir($path);
}
}
array_shift($outfile);
$outfile=implode("\r\n",$outfile);
file_put_contents($filename,$outfile);
}
echo "done.";
?>
切割标记:#file 文件保存路径
$file=<<<html
#file block/head.html
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.cxslide.min.js"></script>
<script type="text/javascript" src="js/custome.js"></script>
</head>
<body class="body_index">
<!--顶部 开始-->
<div id="top_main">
<div id="top">
<div id="top_2"><a href="" target="_blank"><span class="MobileEdition">[手机版] </span></a></div>
</div>
</div>
#file blocks/foot.html
<!--顶部 结束--><!--Logo 开始-->
<div id="logo_main">
<div id="logo"><!--网站Logo 开始-->
<div class="WebLogo"><a href="/" target="_self"><img src="images/logo.png" title="" alt="" /></a></div>
<!--网站Logo 结束--></div>
</div>
<!--Logo 结束--><!--导航条 开始-->
<div id="navigation_main">
<div id="navigation">
<ul class="navigationlist">
#file body.html
html;
//$file=file_get_contents("index.html");
$list=explode("#file",$file);
array_shift($list);
foreach($list as $key){
$outfile="";
$filename="";
$outfile=split("\r\n",$key);
$filename=trim($outfile[0]);
$path=pathinfo($filename,PATHINFO_DIRNAME);
if(!empty($path)){
if(!file_exists($path)){
mkdir($path);
}
}
array_shift($outfile);
$outfile=implode("\r\n",$outfile);
file_put_contents($filename,$outfile);
}
echo "done.";
?>
切割标记:#file 文件保存路径
相关文章推荐
- 一个关于if else容易迷惑的问题
- PHP5.2.*防止Hash冲突拒绝服务攻击的Patch
- 深入理解PHP之匿名函数
- JSP/PHP基于Ajax的分页功能实现
- 关于PHP通过PDO用中文条件查询MySQL的问题。
- 什么是设计模式
- PHP数据库长连接mysql_pconnect的细节
- Php Installing An Expansion
- PHP+Apache在Windows 9x下的安装和配置
- IIS 6 的 PHP 最佳配置方法
- 安装Apache和PHP的一些补充
- Linux Apache+MySQL+PHP
- 建立Apache+PHP+MySQL数据库驱动的动态网站
- PHP 5.3.0 安装分析心得
- apache 环境下 php 的配置注意事项
- ASP.NET、ASP、PHP、JSP之间有什么区别?
- PHP VBS JS 函数 对照表
- C语言实现的统计php代码行数功能源码(支持文件夹、多目录)
- php xml 入门学习资料