I just read the blog post and i though CI developers could come up with a better coded function.
/**
* Converts a string to a valid UNIX filename.
* @param $string The filename to be
* @return $string The filename converted
*/
function convert_to_filename ($string) {
// Replace spaces with underscores and makes the string lowercase
$string = str_replace (" ", "_", $string);
$string = str_replace ("..", ".", $string);
$string = strtolower ($string);
// Match any character that is not in our whitelist
preg_match_all ("/[^0-9^a-z^_^.]/”, $string, $matches);
// Loop through the matches with foreach
foreach ($matches[0] as $value) {
$string = str_replace($value, "", $string);
}
return $string;
}Show your skills people 😊