Created
June 1, 2015 16:37
-
-
Save henrytran9x/b05b8bcbe4511dbae5fd to your computer and use it in GitHub Desktop.
This code convert string Vietnam
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function convert_string_vietnam($text) | |
{ | |
$text = html_entity_decode ($text); | |
$text = preg_replace("/(ä|à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ)/", 'a', $text); | |
$text = str_replace("ç","c",$text); | |
$text = preg_replace("/(è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ)/", 'e', $text); | |
$text = preg_replace("/(ì|í|î|ị|ỉ|ĩ)/", 'i', $text); | |
$text = preg_replace("/(ö|ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ)/", 'o', $text); | |
$text = preg_replace("/(ü|ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ)/", 'u', $text); | |
$text = preg_replace("/(ỳ|ý|ỵ|ỷ|ỹ)/", 'y', $text); | |
$text = preg_replace("/(đ)/", 'd', $text); | |
$text = preg_replace("/(Ä|À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ắ|Ặ|Ẳ|Ẵ)/", 'a', $text); | |
$text = str_replace("Ç","a",$text); | |
$text = preg_replace("/(È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ)/", 'e', $text); | |
$text = preg_replace("/(Ì|Í|Ị|Ỉ|Ĩ)/", 'i', $text); | |
$text = preg_replace("/(Ö|Ò|Ó|Ọ|Ỏ|Õ|Ô|Ồ|Ố|Ộ|Ổ|Ỗ|Ơ|Ờ|Ớ|Ợ|Ở|Ỡ)/", 'o', $text); | |
$text = preg_replace("/(Ü|Ù|Ú|Ụ|Ủ|Ũ|Ư|Ừ|Ứ|Ự|Ử|Ữ)/", 'u', $text); | |
$text = preg_replace("/(Ỳ|Ý|Ỵ|Ỷ|Ỹ)/", 'y', $text); | |
$text = preg_replace("/(Đ)/", 'd', $text); | |
$text = str_replace(" / ","-",$text); | |
$text = str_replace("/","-",$text); | |
$text = str_replace(" - ","-",$text); | |
$text = str_replace("_","-",$text); | |
$text = str_replace(" ","-",$text); | |
$text = str_replace( "ß", "ss", $text); | |
$text = str_replace( "&", "", $text); | |
$text = str_replace( "%", "", $text); | |
$text = ereg_replace("[^A-Za-z0-9-]", "", $text); | |
$text = str_replace("----","-",$text); | |
$text = str_replace("---","-",$text); | |
$text = str_replace("--","-",$text); | |
$text = preg_replace("/( |!||#|$|%|')/", '', $text); | |
$text = preg_replace("/(̀|́|̉|$|>)/", '', $text); | |
$text = preg_replace ("'<[\/\!]*?[^<>]*?>'si", "", $text); | |
$text = strtolower($text); | |
return $text; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment