Created
November 21, 2009 01:15
-
-
Save thinkerytim/239936 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function filename_safe($filename) { | |
$temp = $filename; | |
$temp = strtolower($temp); | |
$temp = str_replace(" ", "_", $temp); | |
// Loop through string | |
$result = ''; | |
for ($i=0; $i<strlen($temp); $i++) { | |
if (preg_match('([0-9]|[a-z]|_)', $temp[$i])) { | |
$result = $result . $temp[$i]; | |
} | |
} | |
return $result; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment