<?php
function Numdatabase () {
$numarr =array ( 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,4 4,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84 , 85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100);
return $numarr;
}
function Hzdatabase () {
$hanziarr = Array ("One", "two", "three", "four", "five", "six", "seven", "eight", "Nine", "Ten", "11", "12", "13", "14", "XV", "16", "17", "18", "19", "20", "21 "," 22 "," 23 "," 24 "," 25 "," 26 "," 27 "," 28 "," 29 "," 30 "," 31 "," 32 "," 33 "," 34 "," 35 "," 36 "," 37 "," 38 "," 39 "," 40 "," 41 "," 42 "," 43 "," 44 "," 45 "," 46 "," 47 "," 48 "," 49 "," 50 "," 51 "," 52 "," 53 "," 54 "," 55 "," 56 "," 57 "," 58 " , "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", " 77 "," 78 "," 79 "," 80 "," 81 "," 82 "," 83 "," 84 "," 85 "," 86 "," 87 "," 88 "," 89 "," 90 "," 91 "," 92 "," 93 "," 94 "," 95 " , "96", "97", "98", "99", "100");
return $hanziarr;
}
function Num2hanzi ($STR) {
$numarr = Numdatabase ();
$hanziarr = Hzdatabase ();
Preg_match ('/[0-9]+/', $str, $t);
$num = intval ($t [0]);
$rstr = ";
if (In_array ($num, $numarr)) {
foreach ($numarr as $k = = $v) {
if ($v = = $num) {
$kk = $k;
}
}
$rstr = Str_replace ($num, $hanziarr [$kk], $STR);
}
return $rstr;
}
Kanji to Digital
function Hanzi2num ($STR) {
$numarr = Numdatabase ();
$hanziarr = Hzdatabase ();
foreach ($hanziarr as $k = = $v) {
if (Strpos ($str, $v)!==false) {
$rstr = Str_replace ($v, $numarr [$k], $STR);
}
}
return $rstr;
}
function Zhuan ($STR) {
$result = ";
$n = Array (' 0 ', ' 1 ', ' 2 ', ' 3 ', ' 4 ', ' 5 ', ' 6 ', ' 7 ', ' 8 ', ' 9 ');
$zi = Array (' One ', ' two ', ' three ', ' four ', ' five ', ' VI ', ' VII ', ' VIII ', ' IX ', ' ten ');
foreach ($zi as $k = = $v) {
if (Strpos ($str, $n [$k])!== false) {
$result = Num2hanzi ($STR);
}
if (Strpos ($str, $v)!== false) {
$result = Hanzi2num ($STR);
}
}
return $result;
}
$str = ' 100 ';
$r = Zhuan ($STR);
Echo $r;
?>
PHP Kanji Digital Transfer (within 100) | PHP Kanji to Digital | PHP Digital to Chinese characters