I want to do a function that generates a string in the alphanumeric format (XXXXXX-XXXXXX) and did the following function to do so:
private static function generateCode() {
function generate() {
$alphaNumeric = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; // ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
$code = '';
for ($i = 0; $i < 6; $i++) {
$code .= $alphaNumeric[ rand(0,strlen($alphaNumeric) - 1) ];
}
return $code; // ex: X0XX0X
}
return sprintf("%s-%s",generate(),generate());
}
But I can not use generate (), how do I get this function inside the other?