rohan.bajaj17 Posted July 25, 2012 Share Posted July 25, 2012 <?php $f="F"; $Cnt=99; //<-- id, value from DB //range of ascii, //A:0-99, B:100-199, C:200-299, ..Z:2600-2699 $asciiPrefix = (int)65; $asciiPrefix += (int)($Cnt/100); $Cnt++; $newValue =$f. chr($asciiPrefix).''.((int)$Cnt%100); echo $newValue; ?> from above code i ll get output on cnt=0 =FA1 Cnt=1=FA2.....CNT=99=A0 but i dont wanna dis like....i wanted an output like dis cnt=1=FA1 Cnt=2=FA2 ....Cnt 99=FA99 and when cnt reaches100 it will be like Cnt=100=FB1....Cnt=198=FB99......Cnt=199=FC1 Cnt=297=FC99 an so on....so guys please give me a solution how to put range A=1 to 99 den B=100 to 198 ....c=199 to 297 and z=2476 to 2574 18716_.php Quote Link to comment https://forums.phpfreaks.com/topic/266218-want-to-set-range-a1-99-b100-198-c-199-297-and-so-on/ Share on other sites More sharing options...
xyph Posted July 25, 2012 Share Posted July 25, 2012 Wouldn't CNT = 100 = FB0 ? Quote Link to comment https://forums.phpfreaks.com/topic/266218-want-to-set-range-a1-99-b100-198-c-199-297-and-so-on/#findComment-1364271 Share on other sites More sharing options...
Psycho Posted July 25, 2012 Share Posted July 25, 2012 $f="F"; $range = 99; $letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; for($Cnt=1; $Cnt<400; $Cnt++) { $cntIndex = floor(($Cnt-1) / $range); $newValue = $f . $letters[$cntIndex] .($Cnt - ($cntIndex * $range)); echo "{$Cnt} : {$newValue}<br>\n"; } Quote Link to comment https://forums.phpfreaks.com/topic/266218-want-to-set-range-a1-99-b100-198-c-199-297-and-so-on/#findComment-1364292 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.