Advertisement
Virajsinh

OTP Generate in PhP

Aug 24th, 2020
1,466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.29 KB | None | 0 0
  1. $otp = substr(str_shuffle("0123456789"), 0, 4);
  2.  
  3. $otp = str_pad(rand(0000,9999), 4, "0", STR_PAD_LEFT); // 4 Digit, add "0" if Length is 5 and generate digit is 4
  4.  
  5. $randomString = substr(str_shuffle("0123456789abcdefghijklmnopqrstvwxyzABCDEFGHIJKLMNOPQRSTVWXYZ"), 0, 11) // string Length 11
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement