PHP Tips && Tricks: Difference between revisions
From D3xt3r01.tk
Jump to navigationJump to search
mNo edit summary |
|||
(One intermediate revision by the same user not shown) | |||
Line 2: | Line 2: | ||
<source lang="php"> | <source lang="php"> | ||
// Windows name doen't allow the following chars: / \ ? < > : * | " | |||
function safename($d){ | function safename($d){ | ||
$d = preg_replace('|[\/\?<>\\\\:*\|" | $d = preg_replace('|[\/\?<>\\\\:*\|"]|i', ' ', $d); | ||
$d = preg_replace('/\s+/', ' ', $d); | $d = preg_replace('/\s+/', ' ', $d); | ||
return trim($d); | return trim($d); | ||
} | } | ||
</ | </source> |
Latest revision as of 15:37, 11 June 2013
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);
}