i have a file with name 2011-08-21-filename.php
I want to extract the date and the title, so the permalink will be something like /2011/08/21/filename
$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"