<?php/*** 将十进制数字转换为二十六进制字母串*/function num2alpha($intNum, $isLower=true){$num26 = base_convert($intNum, 10, 26);$addcode = $isLower ? 49 : 17;$result = '';for ($i=0; $i<strlen($num26); $i++) {$code = ord($num26{$i});if ($code < 58) {$result .= chr($code+$addcode);} else {$result .= chr($code+$addcode-39);}}return $result;}/*** 将二十六进制字母串转换为十进制数字*/function alpha2num($strAlpha){if (ord($strAlpha{0}) > 90) {$startCode = 97;$reduceCode = 10;} else {$startCode = 65;$reduceCode = -22;}$num26 = '';for ($i=0; $i<strlen($strAlpha); $i++) {$code = ord($strAlpha{$i});if ($code < $startCode+10) {$num26 .= $code-$startCode;} else {$num26 .= chr($code-$reduceCode);}}return (int)base_convert($num26, 26, 10);}
1200字范文,内容丰富有趣,写作的好帮手!