Jump to content

Can i convert an integer into its associated ascii?


cooldude832

Recommended Posts

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?


<?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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.