metroid2 Posted March 2, 2013 Report Posted March 2, 2013 (edited) Sveicināi.. Man ir tāda problēma, ar Dāņu burtiem un str_replace.. Piemēram šāds kods: $string = "ÆØÅ æøå"; $find = array(" ", "æ", "ø", "å", "Æ", "Ø", "Å"); $replace = array("-", "ae", "oe", "aa", "ae", "oe", "aa"); $link = str_replace($find,$replace,$string); echo $link; Nostrādā viss kā vajag.. Bet ja $string piemēram iet caur POST vai datubāzi, visa padarīšana izjūk.. Nostrādā tikai atsarpe un viss.. Meklēju google, neko neatradu par šito.. Tikt tracinoši, kad tik vienkāša lieta neiet.. Šāds variants neiet: $find = array(" ", "æ", "ø", "å", "Æ", "Ø", "Å"); $replace = array("-", "ae", "oe", "aa", "ae", "oe", "aa"); $link = str_replace($find,$replace,strtolower($_POST['data']['post_title'])); Edited March 2, 2013 by metroid2 Quote
waplet Posted March 2, 2013 Report Posted March 2, 2013 var_dump($_POST['data']['post_title']); var_dump($string); pasties vai sakrīt. Quote
blackhalt Posted March 2, 2013 Report Posted March 2, 2013 Vajag UTF-8 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>untitled</title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <!-- Slikts ir ISO-8859-1: <meta http-equiv="content-type" content="text/html;charset=ISO-8859-1" /> --> <meta name="generator" content="Geany 0.21" /> </head> <body> <form id="meklis" name="meklis" action="" method="post"> <input name="data" id="data" /> </form> <?php $string = "ÆØÅ æøå"; $find = array(" ", "æ", "ø", "å", "Æ", "Ø", "Å"); $replace = array("-", "ae", "oe", "aa", "ae", "oe", "aa"); $link = str_replace($find,$replace,$string); echo $link; echo '<br />'; if(isset($_POST['data'])){ $link = str_replace($find,$replace,strtolower($_POST['data'])); echo $link; } ?> </body> </html> Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.