Dieses PHP-Script erzeugt einen Zufalls-String mit definierbarer Länge, bestehend aus zufälligen Zahlen und Buchstaben.
<?php
/*
This Software returns random chars a-z/0-9 with given maxlength.
Copyright (C) 2020 Guido Richter / tintenkobold.de
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License [http://www.gnu.org/licenses/] for more details.
*/
// output string length: $charNbr
function random_chars($charNbr)
{
$chars = array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');
$randomchar = '';
for($i=0;$i<$charNbr;++$i)
{
$randomchar .= $chars[rand(0,35)];
}
return $randomchar;
}
?>