Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function textToSmile($s) {
- $arr = array();
- $s = (string) $s;
- $s = str_replace(array("\n", "\r"), " ", $s);
- $s = trim($s);
- $s = function_exists('mb_strtolower') ? mb_strtolower($s) : strtolower($s);
- $s = strtr($s, array('а'=>'a','б'=>'b','в'=>'v','г'=>'g','д'=>'d','е'=>'e','ё'=>'e','ж'=>'j','з'=>'z','и'=>'i','й'=>'y','к'=>'k','л'=>'l','м'=>'m','н'=>'n','о'=>'o','п'=>'p','р'=>'r','с'=>'s','т'=>'t','у'=>'u','ф'=>'f','х'=>'h','ц'=>'c','ч'=>'ch','ш'=>'sh','щ'=>'shch','ы'=>'y','э'=>'e','ю'=>'yu','я'=>'ya','ъ'=>'','ь'=>''));
- $s = preg_replace("/[^0-9a-z-_ ]/i", "", $s);
- $s = preg_split('//u', $s, -1, PREG_SPLIT_NO_EMPTY);
- foreach($s as $value) {
- if($value == " ") {
- $arr[] = ":heart:";
- }else {
- $arr[] = ":regional_indicator_" . $value . ": ";
- }
- }
- return implode("", $arr);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement