Switch Chinese to Arabic to [1] [full screen preview]
Function strToNum ($ str) {$ arr1 = ['0' => '', '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9]; $ arr2 = ['661' => 100000000, '10' => 10000000, 'M1' => 1000000, '123' => 100,000, 'wan' => 10000, 'kilobytes => 1000, '100' => 100, '10' => 10]; preg_match_all ('/(zero | one | two | three | four | five | six | seven | eight | nine | ten | hundreds | thousands | tens | hundreds of millions) +/I ', $ str, $ result); if (empty ($ result [0] [0]) return $ str; else $ tmp = $ result [0] [0]; $ tmp = str_replace (array_keys ($ arr1), array_values ($ ar R1), $ tmp); foreach ($ arr2 as $ k => $ v) {if (strlen ($ tmp) = 1) $ tmpArr [1] = $ tmp; else if (strpos ($ tmp, $ k )! = False) {$ tmpArr [$ v] = getFromStr ('', $ k, $ tmp); $ tmp = getFromStr ($ k,'', $ tmp ); if (strlen ($ tmp) = 1) $ tmpArr [1] = $ tmp;} if (is_array ($ tmpArr) {$ num = 0; foreach ($ tmpArr as $ k => $ v) {if (empty ($ v) $ v = 1; $ num + = $ k * $ v ;}} if (! Empty ($ num) return str_replace ($ result [0] [0], $ num, $ str); else return $ str;} function getFromStr ($ start, $ end, $ str) {if (! Empty ($ start) $ str = substr ($ str, strpos ($ str, $ start) + strlen ($ start), strlen ($ str)-strlen ($ start) -strpos ($ str, $ start); if (! Empty ($ end) $ str = substr ($ str, 0, strpos ($ str, $ end); return $ str ;}