<h1>Generate Random String using PHP</h1>
<?php
function generateRandomString($length=10){
return substr(str_shuffle(str_repeat($x='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',ceil($length/strlen($x)))),1,$length);
}
?>
<p>Random String of 10 characters: <strong><?php echo generateRandomString();?></strong></p>
<p>Random String of 20 characters:<strong><?php echo generateRandomString(20);?></strong></p>
<p>Random String of 4 characters: <strong><?php echo generateRandomString(4);?></strong></p>
<p>Random String of 1 character:<strong><?php echo generateRandomString(1);?></strong></p>