小弟向各位求教了:php遍历完文件后执行遍历的文件 本帖最后由 lukylfm 于 2010-04-14 18:40:03 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在代码顶部加上 set_time_limit(0); 试试 遍历时的程序:我遍历的文件都在 court文件夹下function Readefile($path){ include($path);}foreach(glob("./court/*.php") as $fi){ echo $fi."</br>"; Readefile($fi); //include($fi);}court文件中其中一个的代码,我都是用函数表示的,调用了好些include("../courturl.php");courturl("http://www.agri.gov.cn/blgg/gd/","/(\/t\w{10,}\.htm)/i","http://www.agri.gov.cn/blgg");courturl.php文件中都是函数,下面是上边的文件用到的一个函数function courturl($pageurl,$pattern,$outurl_pre){ $nums=array(); $contents=@file_get_contents($pageurl); preg_match_all($pattern,$contents,$out); foreach($out[1] as $url){ if(in_array($url,$nums)){ continue; } $nums[]=$url; $allurl=$outurl_pre.$url; echo '<a href="'.$allurl.'">'.$allurl."</a></br>"; $sql="insert into phpurl(`url`) values('$allurl')"; mysql_query($sql) or die($sql."</br>".mysql_error()); }} $contents=@file_get_contents($pageurl);把@去掉,它会告诉你在读哪个url的时候断掉了这种读写文件,如果很多,一定要做缓存 if(file_exist("record.txt")) {foreach(....) {file_put_contents("record.txt", $data);file_get_contents();}}else {foreach(从数组循环) {}}断掉了每次刷新一下,就会从文件读入最后断掉的位置,然后继续 wamp2.0会影响ediplus写的文件吗?wamp2.0是否实用? php oa系统介绍 PHP 的自定义函数 how to modify below code to change all to js code? field表单中的路径怎么获取? 简单php采集网页部分文字问题,求指点,多谢 求一sql语句 请教ssesion的暂存路径问题 如何在.pl文件里判断文件路径是否有效,文件名是否有效 我要如何实现提取一个字符串中右起n个字符???????????? 关于PHP EXCEL时间(不是日期)的问题 怎么查看PHP函数的核心源代码呢?
include($path);}
foreach(glob("./court/*.php") as $fi){
echo $fi."</br>";
Readefile($fi);
//include($fi);
}
court文件中其中一个的代码,我都是用函数表示的,调用了好些
include("../courturl.php");
courturl("http://www.agri.gov.cn/blgg/gd/","/(\/t\w{10,}\.htm)/i","http://www.agri.gov.cn/blgg");courturl.php文件中都是函数,下面是上边的文件用到的一个函数
function courturl($pageurl,$pattern,$outurl_pre){
$nums=array();
$contents=@file_get_contents($pageurl);
preg_match_all($pattern,$contents,$out);
foreach($out[1] as $url){
if(in_array($url,$nums)){
continue;
}
$nums[]=$url;
$allurl=$outurl_pre.$url;
echo '<a href="'.$allurl.'">'.$allurl."</a></br>";
$sql="insert into phpurl(`url`) values('$allurl')";
mysql_query($sql) or die($sql."</br>".mysql_error());
}
}
把@去掉,它会告诉你在读哪个url的时候断掉了
这种读写文件,如果很多,一定要做缓存
if(file_exist("record.txt")) {foreach(....) {
file_put_contents("record.txt", $data);
file_get_contents();
}
}else {
foreach(从数组循环) {
}
}
断掉了每次刷新一下,就会从文件读入最后断掉的位置,然后继续