/* EXAMPLE: <p>Bed & Breakfast</p> --> <p>Bed & Breakfast</p>
& &
" " (unless ENT_NOQUOTES is set)
' ' or ' (ENT_QUOTES must be set)
< <
> > */
<?php
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new; // <a href='test'>Test</a>
?>
function removeSpecialChar($string)
{
$string = strtolower($string);
$string = preg_replace('/[^da-z ]/i', '', $string);// Removes special chars.
$string = str_replace(' ', '-', $string); // Replaces all spaces with underscore.
return strtolower($string);
}
$source = 'url of page with text with special characters';
$html = file_get_contents($source,0);
$html = mb_convert_encoding($html, 'UTF-8', mb_detect_encoding($html, 'UTF-8, ISO-8859-1', true));