Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- private function friendly_filename($str) {
- // everything to lower and no spaces begin or end
- $str = strtolower(trim($str));
- //replace accent characters, depends your language is needed
- $str=$this->replace_accents($str);
- // decode html maybe needed if there's html I normally don't use this
- //$str = html_entity_decode($str,ENT_QUOTES,'UTF8');
- $str = escapeshellarg($str);
- // adding - for spaces and union characters
- $find = array(' ', '&', '\r\n', '\n', '+',',');
- $str = str_replace ($find, '_', $str);
- //delete and replace rest of special chars
- $find = array('/[^a-z0-9\-\.<>]/', '/[\-]+/', '/<[^>]*>/');
- $repl = array('', '-', '');
- $str = preg_replace ($find, $repl, $str);
- //return the friendly str
- return $str;
- }
Advertisement
Add Comment
Please, Sign In to add comment