Visa ett inlägg
Oläst 2008-01-02, 16:53 #1
mindphaser mindphaser är inte uppkopplad
Flitig postare
 
Reg.datum: Sep 2006
Inlägg: 423
mindphaser mindphaser är inte uppkopplad
Flitig postare
 
Reg.datum: Sep 2006
Inlägg: 423
Hej,

behöver lite hjälp med att skapa en URL-vänlig sträng, dvs skala bort alla tänkbara specialtecken. Själv trodde jag det skulle gå bra med tex str_replace enligt nedan, men tex tecknen ' : á osv fungerar ej att ersätta. Ny inom PHP så jag har väl missat ngt. Se exempelkod nedan:

Kod:
function urlizeString($aString)
{
	$newTitle = str_replace("(", "", $aString);
	$newTitle = str_replace(")", "", $newTitle);
	$newTitle = str_replace("á", "a", $newTitle);
	$newTitle = str_replace("à", "a", $newTitle);
	$newTitle = str_replace("\'", "", $newTitle);
	$newTitle = str_replace(":", "", $newTitle);
	$newTitle = str_replace("/", "", $newTitle);
	$newTitle = str_replace("?", "", $newTitle);
	$newTitle = str_replace("\"", "", $newTitle);
	$newTitle = str_replace("ö", "oe", $newTitle);	# ö
	$newTitle = str_replace("Ã¥", "au", $newTitle); # å
	$newTitle = str_replace("ä", "ae", $newTitle); # ä 
	$newTitle = str_replace("Ã…", "Au", $newTitle); # Å 
	$newTitle = str_replace("’", "", $newTitle);
	$newTitle = str_replace(",", "", $newTitle);
	$newTitle = str_replace(" ", "_", $newTitle);	
	
	#$newTitle = ereg_replace("[^+A-Za-z0-9]", "", $newTitle =);
	
	return $newTitle;
}
mindphaser är inte uppkopplad   Svara med citatSvara med citat