0

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
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by diafol
0

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.

Edited by diafol: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.