在做Excel上传解析时,为了动态配置Excel与数据库表对应关系,由数组索引关联到Excel的某一列,需要将索引值转换为Excel列标,所以就写了这个方法,现在把代码帖出来,如果有更好的方法还请分享下,谢谢! /**<br>
* 数字转字母 (类似于Excel列标)<br>
* @param Int $index 索引值<br>
* @param Int $start 字母起始值<br>
* @return String 返回字母<br>
* @author Anyon Zou <anyon><br>
* @date 2013-08-15 20:18<br>
*/<br>
function IntToChr($index, $start = 65) {<br>
$str = '';<br>
if (floor($index / 26) > 0) {<br>
$str .= IntToChr(floor($index / 26)-1);<br>
}<br>
return $str . chr($index % 26 + $start);<br>
}<br>
<br>
/**<br>
* 测试<br>
*/<br>
function test() {<br>
echo IntToChr(0); //# A<br>
echo IntToChr(1); //# B<br>
// ...<br>
echo IntToChr(27); //# AB<br>
}</anyon>
AD:真正免费,域名+虚机+企业邮箱=0元

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1
Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
