Generate Random Number in php

function generate_random_password($length = 4) {

    $alphabets = range('A','Z');

    $numbers = range('0','9');

    $additional_characters = array('_','.');

    $final_array = array_merge($alphabets,$numbers,$additional_characters);

   $password = '';

while($length--) {
 $key = array_rand($final_array);

$password .= $final_array[$key];
  }
  return $password;
}

$pass1 = generate_random_password(4);

Leave a Reply

Your email address will not be published. Required fields are marked *