Jump to content
php.lv forumi

str replace Dāņu burti


metroid2

Recommended Posts

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 by metroid2
Link to comment
Share on other sites

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>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...