<?php function _random(string $set , int $length): string { $setLength = strlen($set); $randomKey = random_int(0, $setLength - 1); $firstPiece = substr($set, 0, $randomKey); $secondPiece = substr($set, $randomKey, $setLength - $randomKey); $removedCharacter = $firstPiece[strlen($firstPiece) - 1] ?? null; if(null === $removedCharacter || $length === 0) { return ''; } $firstPieceWithoutTheLastChar = substr($firstPiece, 0, -1); return $removedCharacter . _random($firstPieceWithoutTheLastChar . $secondPiece, $length - 1); } $a = _random('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 32); $b = _random('abcdefghijklmnopqrstuvwxyz', 8); $c = _random('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 64); var_dump($a, $b, $c);
You have javascript disabled. You will not be able to edit any code.