Today, We want to share with you PHP Generate Random shuffles Strings Example.
In this post we will show you 4 digit pin generator, hear for php generate random number we will give you demo and example for implement.
In this post, we will learn about Generate a random string A-Z, 0-9 in PHP with an example.
PHP Generate Random shuffles Strings Example
Contents
There are the Following The simple About PHP Generate Random shuffles Strings Full Information With Example and source code with other php generate random number, php generate random alphanumeric string and 4 digit pin generator.
Making The Interface
index.php
<!DOCTYPE html> <html lang="en"> <head> <title>Generate a random string A-Z, 0-9 in PHP<title> <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" /> <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/> </head> <body> <nav class="navbar navbar-default"> <div class="container-fluid"> <a class="navbar-brand" href="<a href="https://www.pakainfo.com">pakainfo</a> </a> </div> </nav> <div class="col-md-3 pakainfo"></div> <div class="col-md-6 well"> <h3 class="text-success">PHP simple Generate Random Strings examples</h3> <hr style="border-top:1px dotted #ccc;"/> <div class="col-md-3"></div> <div class="col-md-6"> <form method = "POST"> <div class="form-group infinity"> <label>Enter Total length</label> <input type="number" min="1" max="12" name="totallen" class="form-control" require="required"/> </div> <?php include 'generate.php'?> <center><button class="btn btn-info" name="generate"><span class="glyphicon glyphicon-random"></span> Generate</button></center> </form> </div> </div> </body> </html>
Creating the Main Function
generate.php
<?php function GenerateString($totallen) { //Generate a random string A-Z, 0-9 in PHP $mystr = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $stringLength = strlen($mystr); $latestStr = ''; for ($i = 0; $i < $totallen; $i++) { $latestStr .= $mystr[rand(0, $stringLength - 1)]; } return $latestStr; } if(ISSET($_POST['generate'])){ $totallen = $_POST['totallen']; echo '<center><h3 style="border:1px solid #000; padding:5px;" class="text-success">'.GenerateString($totallen).'</h3></center>'; } ?>
retype-new-password
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about PHP – Generate Random Strings Example.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, donβt forget to share.
I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I’m a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.