DreadyCrig
6/13/2018 - 4:59 PM

Returns random characters

Returns random characters

function _make_token( $length = 16 )
{
	$token = "";
	$codeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	$codeAlphabet.= "abcdefghijklmnopqrstuvwxyz";
	$codeAlphabet.= "0123456789";
	$max = strlen($codeAlphabet); // edited
	for ($i=0; $i < $length; $i++) {
		token .= $codeAlphabet[random_int(0, $max-1)];
	}
	return $token;
}
<?php

$length = 8;
$x      = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$name   = substr( str_shuffle( str_repeat( $x, ceil( $length / strlen( $x ) ) )), 1, $length );
$name   = str_replace( array( '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', ), '', $name );
$two    = substr( $name, 0, 2 );

$path   = $root . $two . '/';