cooldude832 Posted June 4, 2007 Share Posted June 4, 2007 I have this: $rnd[0] = rand(48,57); $rnd[1] = rand(48,57); $rnd[2] = rand(65,90); $rnd[3] = rand(65,90); $rnd[4] = rand(65,90); $rnd[5] = rand(48,57); $rnd[6] = rand(48,57); Is there a way I can reproduce those numbers into associated ascii values like if $rnd[0] = 46 its the number 8 or if rnd[3] is 75 its K? Quote Link to comment https://forums.phpfreaks.com/topic/54189-can-i-convert-an-integer-into-its-associated-ascii/ Share on other sites More sharing options...
redarrow Posted June 4, 2007 Share Posted June 4, 2007 one example to test the rest is easy. <?php $rnd = rand(48,90); $res=chr($rnd); echo $res; ?> Quote Link to comment https://forums.phpfreaks.com/topic/54189-can-i-convert-an-integer-into-its-associated-ascii/#findComment-267923 Share on other sites More sharing options...
cooldude832 Posted June 4, 2007 Author Share Posted June 4, 2007 yeah i realized chr afterwards its for a password recovery system generates the password in the form NNCCCCNN from the random numbers. Quote Link to comment https://forums.phpfreaks.com/topic/54189-can-i-convert-an-integer-into-its-associated-ascii/#findComment-267927 Share on other sites More sharing options...
redarrow Posted June 4, 2007 Share Posted June 4, 2007 <?php function randomkeys($length) { $pattern = "1234567890abcdefghijklmnopqrstuvwxyz"; for($i=0;$i<$length;$i++) { $key .= $pattern{rand(0,35)}; } return $key; } echo randomkeys(,"<br>"; echo randomkeys(16),"<br>"; echo randomkeys(32),"<br>"; echo randomkeys(64),"<br>"; ?> this is better ok Quote Link to comment https://forums.phpfreaks.com/topic/54189-can-i-convert-an-integer-into-its-associated-ascii/#findComment-267934 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.