$content = @filter_var($content, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
Reference: https://ithelp.ithome.com.tw/questions/10191261
function getCleanedName($filename){
$result = '';
$strlen = strlen($filename);
for($i=0; $i<$strlen; $i++){
$char = substr($filename, $i, 1);
// 0-9
for($j = 48; $j < 58; $j++){
if($char === chr($j)){
$result .= chr($j);
}
}
// A-Z
for($j = 65; $j < 91; $j++){
if($char === chr($j)){
$result .= chr($j);
}
}
// a-z
for($j = 97; $j < 123; $j++){
if($char === chr($j)){
$result .= chr($j);
}
}
// other valid characters
switch($char){
case '-':
$result .= '-';
break;
case '_':
$result .= '_';
break;
case '(':
$result .= '(';
break;
case ')':
$result .= ')';
break;
case ' ':
$result .= ' ';
break;
}
}
return $result;
}