使用phpQuery实现批量文件处理

能够将置顶文夹下的指定类型文件进行处理

<?php
header('Content-Type:text/html;Charset=utf-8');
include './phpQuery/phpQuery.php'; $path = 'file';
if(is_dir($path))
{
if ($dh = opendir($path))
{
while (($file = readdir($dh)) !== false)
{
if($file == '.' || $file =='..'){
continue;
}
if(!is_dir($file)){
echo $file.'<br/>';
exchange($path.'/'.$file);
} }
closedir($dh);
}else{
echo 111;
}
}else{
echo 22222;
} function exchange($file){
$path = $file;
$file = file_get_contents($path); phpQuery::newDocumentHTML($file);
$artlist = pq("a");
foreach($artlist as $li){
$str = pq($li)->attr('href');
$str2 = $str; if(strstr($str,'javascrip') || strstr($str,'#') || empty($str)){continue;} if(strstr($str,'http')){
$str = 'http://qhmoney.cn'.substr($str,strrpos($str,'/'));
}else{
$str = 'http://qhmoney.cn/'.$str;
}
//echo $str.'<br/>'; $file = str_replace($str2,$str,$file);
file_put_contents($path,$file); } }
?>
上一篇:bzoj 4974: 字符串大师


下一篇:PureMVC(JS版)源码解析(八):Proxy类