function numberToChinese($number)
{
$number = intval($number);
$bit = array("零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十");
//各位数
if ($number <= 10) {
return $bit[$number];
}
//十位数
if ($number < 100) {
$array = str_split($number);
if ($array[0] < 2) {
return $bit[10] . $bit[$array[1]];
} else {
if ($array[1] == 0) {
return $bit[$array[0]] . $bit[10];
} else {
return $bit[$array[0]] . $bit[10] . $bit[$array[1]];
}
}
}
//百位数
if ($number < 1000) {
$array = str_split($number);
if ($array[1] == 0 && $array[2] == 0) {
return $bit[$array[0]] . "百";
} elseif ($array[1] == 0 && $array[2] != 0) {
return $bit[$array[0]] . "百" . $bit[$array[1]] . $bit[$array[2]];
} elseif ($array[1] != 0 && $array[2] == 0) {
return $bit[$array[0]] . "百" . $bit[$array[1]] . $bit[10];
} else {
return $bit[$array[0]] . "百" . $bit[$array[1]] . $bit[10] . $bit[$array[2]];
}
}
//千位数
if ($number < 10000) {
$array = str_split($number);
if ($array[1] == 0 && $array[2] == 0 && $array[3] == 0) {
return $bit[$array[0]] . "千";
} elseif ($array[1] == 0 && $array[2] != 0 && $array[3] != 0) {
return $bit[$array[0]] . "千" . $bit[$array[1]] . $bit[$array[2]] . $bit[10] . $bit[$array[3]];
} elseif ($array[1] == 0 && $array[2] == 0 && $array[3] != 0) {
return $bit[$array[0]] . "千" . $bit[$array[1]] . $bit[$array[3]];
} elseif ($array[1] == 0 && $array[2] != 0 && $array[3] == 0) {
return $bit[$array[0]] . "千" . $bit[$array[1]] . $bit[$array[2]] . $bit[10];
} elseif ($array[1] != 0 && $array[2] == 0 && $array[3] == 0) {
return $bit[$array[0]] . "千" . $bit[$array[1]] . "百";
} elseif ($array[1] != 0 && $array[2] != 0 && $array[3] == 0) {
return $bit[$array[0]] . "千" . $bit[$array[1]] . "百" . $bit[$array[2]] . $bit[10];
} elseif ($array[1] != 0 && $array[2] == 0 && $array[3] != 0) {
return $bit[$array[0]] . "千" . $bit[$array[1]] . "百" . $bit[$array[2]] . $bit[$array[3]];
} else {
return $bit[$array[0]] . "千" . $bit[$array[1]] . "百" . $bit[$array[2]] . $bit[10] . $bit[$array[3]];
}
}
return $number;
}