I have some strings that contain & # 234 ; or other special character, i want to normalise them so i can use them in database, urls etc.

What i started is below, but i can not belief there isn't a php function for it, anyone now which one?

$phrase = 'itali& # 234 ;';
			
$find   = 

array("ì","í","î","ï","ï","î","í","ì","ù"
,"ú","û","ü","ü","û","ú","ù","ç","ç","ì",
"í","î","ï","ë","ê","é","è","è",
"é","ê","ë","ë","à","á","â","ã","ä","å","à","á","â",
"ã","ä","å",".","!",",",":",";","'","\"","ù","ú","û",
"ü","ý","þ","ÿ","ù","ú","û","ü","ý",
"þ","ÿ");

$replace  	= array("i","i","i","i","i","i","i","i","u","u","u","u","u","u","u","u","c","c",
"i","i","i","i","e","e","e","e","e","e","e","e","e","a","a","a","a","a","a","a",
"a","a","a","a","a","","","","","","","","u","u","u","u","u","u","u","u","u","u",
"u","u","u","u");
				
$slug = str_replace($find, $replace, $phrase);

// slug is : italie
Member Avatar for diafol

html_entities() and html_entity_decode() will do most of the symbols you note. In php, there shouldn't be a need to use html encoding.

For urls, have a look at the php manual on urlencode(). htmlentities usually does the job though.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.