public function alpha2num($column) { $number = 0; foreach(str_split($column) as $letter){ $number = ($number * 26) + (ord(strtolower($letter)) - 96); } return $number; } function num2alpha($n) { if ($n > 26) { return num2alpha(($n % 26)?(($n - ($n % 26)) / 26):(($n - ($n % 26)) / 26-1)) . strtoupper(($n % 26)?chr(96 + ($n % 26)):chr(96 + 26)); } else { return strtoupper(chr(96 + $n)) . ''; } }
本文为看恩吧原创文章,转载无需和我联系,但请注明来自knsay.com