目录's tag archives

按ID返回一个二级目录

/* 二级目录 作者:enjoy http://www.9enjoy.com 按ID返回一个二级目录,用于将内容平均分布在36*36个目录中。 36个目录为a-z0-9 */ function IDcat($id){ $p0 = $id % 1296; $p1 = ceil($p0 / 36)-1; $p2 = ($p0-1) % 36 ; return IDnum($p1).'/'.IDnum($p2).'/'; } function IDnum($i){ if($i<10){ if($i==-1){ return 'z'; }else{ return $i; } }else{ return...

连续建目录

/* * 功能:连续建目录 * $dir 目录字符串 */ function makedir( $dir, $mode = "0777" ) { if( ! $dir ) return 0; $dir = str_replace( "\\", "/", $dir ); $rootdir = "./"; $mdir = ""; foreach( explode( "/", $dir ) as $val ) { $mdir .= $val."/"; $newmdir=""; if( $val == ".." || $val == "." || $val="") continue; $newmdir = $rootdir.$mdir; if( ! file_exists( $newmdir ) ) { mkdir($newmdir); chmod($newmdir,$mode); if(! file_exists( $newmdir )){ echo "创建目录...

SureRemoveDir-删除目录

// ggarciaa at gmail dot com (04-July-2007 01:57) // I needed to empty a directory, but keeping it // so I slightly modified the contribution from // stefano at takys dot it (28-Dec-2005 11:57) // A short but powerfull recursive function // that works also if the dirs contain hidden files // // $dir = the target directory // $DeleteMe = if true delete also $dir, if false leave it alonefunction SureRemoveDir($dir, $DeleteMe) { if(!$dh = @opendir($dir)) return; while (false !==...