php random string generator
function generateRandomString($length = 25) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
//usage
$myRandomString = generateRandomString(5);//generates 13 character random unique alphanumeric id
echo uniqid();
//output - 5e6d873a4f597function rand_str() {
$characters = '0123456789-=+{}[]:;@#~.?/>,<|\!"£$%^&*()abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomstr = '';
for ($i = 0; $i < random_int(50, 100); $i++) {
$randomstr .= $characters[rand(0, strlen($characters) - 1)];
}
return $randomstr;
}<?php
function RandomString()
{
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randstring = '';
for ($i = 0; $i < 10; $i++) {
$randstring = $characters[rand(0, strlen($characters))];
}
return $randstring;
}
RandomString();
echo $randstring;
Also in PHP:
- SET CURRENT DATE TIME IN PHP'
- best way to redirect with php
- acf auto increment field
- cambiar entre versiones de php linux
- check if a key is in an array
- array_combine function in php
- character lenght php
- Jan 5, 2021 15:37:25 time format php
- convert time to string in php
- eloquent all only one culomn
- array kley exists php
- Connect to SQL in a php PDO and print the data in it
- create DateTime from timestamp php
- Y-m-d H:
- base decode 64 php
- file_get_contents(): SSL: The operation completed successfully but file_get_contents(http://www.b2bsoftwareking.com): failed to open stream: No connection could be made because the target machine actively refused it. in
- How to change add to cart button in wordpress
- enablequerylog laravel
- clave generator php
- factoring and seeding in laravel
- failed to clear cache laravel
- SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
- code cache laravel
- display date time in php