PHP Tips && Tricks

From D3xt3r01.tk
Jump to navigationJump to search

Windows Safe directory name

// Windows name doen't allow the following chars: / \ ? < > : * | "
function safename($d){
        $d = preg_replace('|[\/\?<>\\\\:*\|"]|i', ' ', $d);
        $d = preg_replace('/\s+/', ' ', $d);
        return trim($d);
}