create randome string php
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);function generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
Output the random string with the call below:
// Echo the random string.
// Optionally, you can give it a desired string length.
echo generateRandomString();
Also in PHP:
- detect the datatype of a value php
- find array unique php
- detail error in php code
- date now php different
- array php missing key
- cache clear in laravel command
- composer takes older version of php
- error log all php
- control type variable php
- date formats php
- Laravel model and migration Generator tutorial
- SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; users_table
- date() format in php
- add column in laravel migration
- change background color with user option
- decode ' php
- codeigniter email print debugger
- ampps php mkdir recreate
- automatic refresh page php
- artisan run seeder
- FORMATA DATA COM PHP
- Sy ntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`)
- catch custom exception ph[
- Error message: Allowed memory size of bytes exhausted wordpress