note 106002 added to function.chr

From: Date: Sat, 01 Oct 2011 13:26:06 +0000
Subject: note 106002 added to function.chr
Groups: php.notes 
Request: Send a blank email to php-notes+get-183580@lists.php.net to get a copy of this message
There is simple function for converting number to chars. If you want make table like excel where colums are indetified by chars A,B,C...AA,AB.. you can easyli iterate on integer and call this function. <?php function numtochars($num,$start=65,$end=90) { $sig = ($num < 0); $num = abs($num); $str = ""; $cache = ($end-$start); while($num != 0) { $str = chr(($num%$cache)+$start-1).$str; $num = ($num-($num%$cache))/$cache; } if($sig) { $str = "-".$str; } return $str; } ?> ---- Server IP: 89.187.142.233 Probable Submitter: 78.111.124.152 ---- Manual Page -- http://www.php.net/manual/en/function.chr.php Edit -- https://master.php.net/note/edit/106002 Del: integrated -- https://master.php.net/note/delete/106002/integrated Del: useless -- https://master.php.net/note/delete/106002/useless Del: bad code -- https://master.php.net/note/delete/106002/bad+code Del: spam -- https://master.php.net/note/delete/106002/spam Del: non-english -- https://master.php.net/note/delete/106002/non-english Del: in docs -- https://master.php.net/note/delete/106002/in+docs Del: other reasons-- https://master.php.net/note/delete/106002 Reject -- https://master.php.net/note/reject/106002 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#183580) next »