Sumber Kode

Create Random Code

  • anonymous
  • Apr 22' 14
  • PHP
  • 1005
  • 13
  • United States

this source code

 

function generateConfirmCode($length) {
	  //random by number and alphabet
	  rand ((double) microtime() * 10000000);
	  
	  $input = array ("A", "B", "C", "D", "E","F","G","H","I","J","K","L","M","N","O","P","Q",
	  "R","S","T","U","V","W","X","Y","Z","a", "b", "c", "d", "e","f","g","h","i","j","k","l","m","n","o","p","q",
      "r","s","t","u","v","w","x","y","z");

      $random_generator="";
      for($i=1;$i<$length+1;$i++){ 
         if(rand(1,2) == 1){
         $rand_index = array_rand($input);
         $random_generator .=$input[$rand_index]; 
         }else{
         $random_generator .=rand(0,9); 
         } 
      } 
     return $random_generator;
	}

Share

  • Tags : code, random, confirmation
comments powered by Disqus

Kode Terkait

Select a random datarecord



Kategori

Tag Terhubung