*/
代码如下 |
复制代码 |
$format ='php';
$path ='www.111com.net/';
$files = getfile($path,$format);
foreach( $files as $v )
{
$tv = basename($v);
list($name,$ext) = explode('.',$tv);
$newname =$path.time().mt_rand(1,10000).'.'.$ext;
if(rename($v,$newname))
{
echo '成功将'.$v.'重命名'.$newname.' ';
}
}
function getfile($path,$format)
{
$dirs = array();
foreach(glob("$path*") as $d)
{
$tmp = explode('.',$d);
$k = end($tmp);
if(is_file($d) && ($k ==strtolower($format) ))
{
$dirs[] = $d;
}
}
return $dirs;
}
|
/*
成功将rename/12819320034756.php重命名rename/12819402065296.php
成功将rename/12819320036890.php重命名rename/12819402067216.php
成功将rename/12819320037133.php重命名rename/12819402067656.php
本站原创教程,坟载注明来源http://www.111com.net/phper/php.html
*/
?>