- htmlentities: documentation ( source)
- preg_replace: documentation ( source)
<?php
$string = 'HDO Intranet — Futar.png';
$encoded = htmlentities($string);
$result = $encoded;
$result = preg_replace('/[^a-zA-Z\d\s-_\.]/', '', $result);
echo $encoded;