code: private function sanitize($string, $force_lowercase = true)
      {
          $strip = array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]",
              "}", "\\", "|", ";", ":", "\"", "'", "&#8216;", "&#8217;", "&#8220;", "&#8221;", "&#8211;", "&#8212;",
              "â€”", "â€“", ",", "<", ".", ">", "/", "?");
          $clean = trim(str_replace($strip, "", strip_tags($string)));
          $clean = preg_replace('/\s+/', "-", $clean);
  
          return ($force_lowercase) ?
              (function_exists('mb_strtolower')) ?
                  mb_strtolower($clean, 'UTF-8') :
                  strtolower($clean) :
              $clean;
      }
docs: Create safe file names for server side
  
  @param $string
  @param bool $force_lowercase
  @return mixed|string