function generate_random_password($length = 10) { $alphabets = range('A','F'); $alphalo = range('a', 'f'); $numbers = range('0','9'); $additional_characters = array('$','-','*','?'); $final_array = array_merge($alphabets,$alphalo,$numbers,$additional_characters); $password = ''; while($length--) { $key = array_rand($final_array); $password .= $final_array[$key]; } return $password; } echo 'Random password generated is "<b>' . generate_random_password(20) . '</b>".';