programming-examples/php/Math/PHP function to create a human-readable random string for a captcha..php
2019-11-15 12:59:38 +01:00

14 lines
250 B
PHP

<?php
function random_string($length = 5)
{
$chars = 'bcdfghjklmnpqrstvwxyzaeiou';
for ($x = 0; $x < $length; $x++)
{
$result .= ($x%2) ? $chars[mt_rand(19, 23)] : $chars[mt_rand(0, 18)];
}
return $result;
}
echo random_string();
?>