This is a sample project for the nubs/random-name-generator
composer package.
First, install the dependencies (I created the composer.json
file by running composer require nubs/random-name-generator
):
composer install
I hereby claim:
To claim this, I am signing this object:
<?php | |
$code = ''; | |
$code = preg_replace('/^<\?/', '', $code); | |
$specialChars = implode('', array_unique(str_split(preg_replace('#[a-z0-9+/]+#i', '', $code)))); | |
file_put_contents('php://stderr', "Special Characters: " . var_export($specialChars, true) . "\n"); | |
$unusedChars = implode('', array_diff( | |
str_split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/+'), | |
array_unique(array_diff(str_split($code), str_split($specialChars))) |
[
): 210]
): 210Array to string conversion is the only way to get access to a useful string in PHP. We luck out that the conversion includes an uppercase A
, otherwise we may not be able to get uppercase letters without including other characters.
): 1!
): 1,
): 1The only real way of generating these from alphabetic letters is to use binary operators like ^
. For example, we could take advantage of the fact that d^H==','
, h^H==' '
, and i^H=='!'
. This should make it possible to remove these three characters adding only the ^
operator.