2011-10-15 78 views

回答

1
$filename = "2011-08-21-filename.php"; 
preg_match('/(\d{4})-(\d{2})-(\d{2})-(\w*).php/', $filename, $matches); 
$path = implode("/", array_slice($matches, 1)); // => string(19) "2011/08/21/filename" 
-1
$filename = str_replace(".php", "", preg_replace("/[0-9-]/", "", $string)); 
$directory = $dir.$filename; 

快速的解決方案,對不起,我不是那麼好用正則表達式