標題說大部分,但反正...
我從獲取數據一個輸入文件,在數據裏面我們會有字符é。就我們的目的而言,我們希望將其轉換爲常規小寫字母e。
有誰知道該怎麼做?
標題說大部分,但反正...
我從獲取數據一個輸入文件,在數據裏面我們會有字符é。就我們的目的而言,我們希望將其轉換爲常規小寫字母e。
有誰知道該怎麼做?
只是一個字符?這似乎太明顯了......只需更換即可。
$str = "é";
$str = str_replace("é","e",$str);
echo $str; // "e"
雖然這是正確的事實證明,我的問題是,在我的輸入最終沒有被確認爲一個é,而是完全是其他的東西。我試過你的代碼,它確實有效(上一次我相信其他人說的沒有工作)。 – 2010-11-12 12:55:20
http://php.net/manual/en/function.str-replace.php
$myText = str_replace(array('é'), array('e'), $myText);
$ string = str_replace('é','e',$ string);從PHP網站
PHP Function: string strtr (string $str , string $from , string $to)
:
我會用這個
<?php
//In this form, strtr() does byte-by-byte translation
//Therefore, we are assuming a single-byte encoding here:
$addr = strtr($addr, "äåö", "aao");
?>
這就是所謂的[音譯](http://en.wikipedia.org/wiki/Transliteration )。 – Gumbo 2010-11-08 16:21:38
不是3542717的確切副本.OP不詢問如何替換所有口音。 – webbiedave 2010-11-08 16:22:24
@webbiedave:我認爲這只是他實際做的簡化。但如果我錯了,我願意重新打開這個問題。 – Gumbo 2010-11-08 16:27:07