note 48220 deleted from function.chr by danbrown

From: Date: Wed, 15 Sep 2010 21:16:07 +0000
Subject: note 48220 deleted from function.chr by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-172603@lists.php.net to get a copy of this message
Note Submitter: ---- Same function as suggested by tippy2k/jmartin. tippy2k's code seems to have a syntax error in the function declaration; jmartin's code throws a notice. So here's yet another version, without temporary variables and loops: <? // 1 <= $a <= 702 function col2str($a) { return ($a-->26?chr(($a/26+25)%26+ord('A')):'').chr($a%26+ord('A')); } // Example $colname = col2str(1) // returns "A" $colname = col2str(27) // returns "AA" $colname = col2str(702) // returns "ZZ" ?>

« previous php.notes (#172603) next »