Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Contributor: Ravishankar ChavareGenerate 4 digit otp
#1
Code:
    function generateOTP($digits = 4){
   $i = 0; //counter
   $pin = ""; //our default pin is blank.
   while($i < $digits){
       //generate a random number between 0 and 9.
       $pin .= mt_rand(0, 9);
       $i++;
   }
   return $pin;
}


now call this generateOTP();

anywhere in php file you will get response in 4 digit if you need 6 digit otp just call 
PHP Code:
$otp=generateOTP(6); 
Reply


Messages In This Thread
Generate 4 digit otp - by Ravishankar Chavare - 03-11-2018, 09:53 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)