Advertisement
myapit

PHP Random Number With Alphabet

May 24th, 2019
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <?php
  2.  
  3. function randomkey(){ return substr(str_shuffle(str_repeat("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", 10)), 0, 6); }
  4.  
  5. for ($i=0;$i<5;++$i)
  6.   echo randomkey()."\n";
  7.  
  8.  
  9.  function random_string($length) {
  10.     $key = '';
  11.     $keys =             array("↑","↓","→","←","2↑","2↓","2→","2←","3↑","3→","3↓","3←");
  12.     for ($i = 0; $i < $length; $i++) {
  13.       $key .= $keys[array_rand($keys)];
  14.     }
  15.     return $key;
  16.     }
  17.     $rand_string = random_string(15);
  18.     echo htmlentities($rand_string);
  19.  
  20. public function code_generator($max_num = 6, $prefix = "PGD")
  21.     {
  22.         if ( (strlen(self::TOTAL_MAX_LIMIT)+$max_num) > self::TOTAL_MAX_LIMIT ) {
  23.             return false;
  24.         } else {
  25.  
  26.             $min = pow(10, $max_num - 1) ;
  27.             $max = pow(10, $max_num) - 1;
  28.             return $prefix.mt_rand($min, $max);
  29.             ///return $prefix.mt_rand($max_num,$max_num); /* return fix length of number */
  30.         }
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement