Answers for "php random letter"

PHP
28

PHP random string generator

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
6

php random string

function rand_str() {
    $characters = '0123456789-=+{}[]:;@#~.?/&gt;,&lt;|\!"£$%^&amp;*()abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $randomstr = '';
    for ($i = 0; $i < random_int(50, 100); $i++) {
      $randomstr .= $characters[rand(0, strlen($characters) - 1)];
    }
    return $randomstr;
  }
Posted by: Guest on October-03-2020
1

random string generator php

<?php
    function RandomString()
    {
        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        $randstring = '';
        for ($i = 0; $i < 10; $i++) {
            $randstring = $characters[rand(0, strlen($characters))];
        }
        return $randstring;
    }

    RandomString();
    echo $randstring;
Posted by: Guest on July-11-2020
0

Generate Random String in PHP

phpCopy<?php 
$Random_str = uniqid();  
echo "Random String:", $Random_str, "\n";
?>
Posted by: Guest on April-23-2021
0

Generate Random String in PHP

phpCopy<?php
 
echo "Out1: ",substr(md5(time()), 0, 16),"\n";
 
echo "Out2: ",substr(sha1(time()), 0, 16),"\n";
 
echo "Out3: ",md5(time()),"\n";
 
echo "Out4: ",sha1(time()),"\n";
 
?>
Posted by: Guest on April-23-2021
0

Generate Random String in PHP

phpCopy<?php
 
echo "Output-1: ",bin2hex(random_bytes(10)),"\n";
 
echo "Output-2: ",bin2hex(random_bytes(20)),"\n";
 
echo "Output-3: ",bin2hex(random_bytes(24)),"\n";
 
?>
Posted by: Guest on April-23-2021

Browse Popular Code Answers by Language