How to create random string in PHP
Sometimes people wants random name like image name, Personal name, book name, etc.... Here i give you short example of random string.
<?php
$char = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomString = '';
$length = 10;
for ($i = 0; $i < $length; $i++) {
$randomString .= $char[rand(0, strlen($char) - 1)];
}
echo $randomString;
?>
No comments:
Post a Comment