Answers for "generate random characters php"

PHP
8

how to create random alphanumeric in php

<?php 
// online code for creating alphanumeric in php 
// this will generate 6 charactor, you can create as many just change the 6 from code
$pass = substr(str_shuffle("0123456789abcdefghijklmnopqrstvwxyz"), 0, 6);
echo $pass;

//output : 17w2y8
?>
Posted by: Guest on July-02-2020
28

php generate random alphanumeric string

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);
Posted by: Guest on October-30-2019
-1

Generate Random String in PHP

phpCopy<?php
function random_str_generator ($len_of_gen_str){
    $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    $var_size = strlen($chars);
    echo "Random string ="; 
    for( $x = 0; $x < $len_of_gen_str; $x++ ) {  
        $random_str= $chars[ rand( 0, $var_size - 1 ) ];  
        echo $random_str;  
    }
echo "\n";
}
random_str_generator (8)
?>
Posted by: Guest on April-23-2021

Code answers related to "generate random characters php"

Browse Popular Code Answers by Language