note 41531 modified in function.chr by vrana

From: Date: Tue, 17 Aug 2004 14:54:39 +0000
Subject: note 41531 modified in function.chr by vrana
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-79861@lists.php.net to get a copy of this message
Here is a function that will convert column numbers in to a letters for use in a spreadsheet. It is limited up to 'ZZ' but can easliy by modifed. <?php function col2chr($a){ if($a<27){ return strtoupper(chr($a+96)); }else{ while($a > 26){ $b++; $a = $a-26; } $b = strtoupper(chr($b+96)); $a = strtoupper(chr($a+96)); return $b.$a; } } ?> --was-- Here is a function that will convert column numbers in to a letters for use in a spreadsheet. It is limited up to 'ZZ' but can easliy by modifed. function col2chr($a){ if($a<27){ return strtoupper(chr($a+96)); }else{ while($a > 26){ $b++; $a = $a-26; } $b = strtoupper(chr($b+96)); $a = strtoupper(chr($a+96)); return $b.$a; } } http://php.net/manual/en/function.chr.php

« previous php.notes (#79861) next »