2014-12-03 141 views
0

以ASCII我需要一個PHP腳本,某些特殊字符轉換爲ASCII碼(,/ - 。和所有帶重音的字母)轉換某些特殊字符在PHP

如。

original: 
Dingo a accidentellement fait tomber la pièce porte-bonheur de Mickey tout au fond du lac. Le Professeur Von Drake va utiliser son camping-car et le transformer en sous-marin pour explorer les eaux profondes. 

result: 
Dingo a accidentellement fait tomber la pièce porte-bonheur de Mickey tout au fond du lac. Le Professeur Von Drake va utiliser son camping-car et le transformer en sous-marin pour explorer les eaux profondes. 

我試着用htmlspecialchars()似乎並不工作時纔會轉換這是在HTML特殊意義的字符

+0

不知道這是否有幫助http://php.net/manual/en/function.ord.php – 2014-12-03 23:33:59

回答

0

如果你看看htmlspecialchars()的文檔,你會看到:

如果您需要具有關聯命名實體進行翻譯的所有輸入子字符串,使用htmlentities()而不是

+0

htmlentities($ str,ENT_QUOTES);它轉換它的一部分,但它並沒有真正轉換「短劃線,逗號,斜槓和所有其他標點」 – Alex 2014-12-04 00:27:09

+0

爲什麼你試圖做到這一點?如果你解釋,可能會有更好的解決方案。我感覺我們正在處理[XY問題](http://meta.stackexchange.com/a/66378);) – 2014-12-04 00:34:45

+0

我得到了一個示例xml文件,將其轉換爲一大堆不同的格式,其中一個將所有的標點符號和東西轉換成ascii代碼,我不知道該怎麼做。 – Alex 2014-12-04 00:44:47