[ol]//转换为人性化数字 function human_num($num) { if (is_numeric($num)) { if ($num > 100000000) { return round($num / 100000000, 1) . '亿'; } elseif ($num > 10000) { return round($num / 10000, 1) . '万'; } else { return $num; } } return $num; }[/ol]复制代码
[ol]function num2zh($num) { $char = array('','一','二','三','四','五','六','七','八','九'); $unit = array('','十','百','千','万'); $num_str = (string)$num; $len = strlen($num_str); $result = ''; $i = 0; while ($i 0) { $result .= $char[$n] . $unit[$len - $i - 1]; } else { if ($result[strlen($result) - 1] != $char[0]) { $result .= $char[0]; } } $i++; } if ($result[strlen($result) - 1] == $char[0]) { $result = substr($result, 0, -1); } return $result; } $num = 10000; $zh = num2zh($num); echo $zh; // 输出:一万 [/ol]复制代码 来自chatgpt