Using the math functions

How to calculate the distance between two points

<?php
  password_length = 8;
 
  // Add a symbol to the password
  $symbols  = '~!@#$%^&*()-_=+[]{};:,.<>?';
  $symbol_count = strlen($symbols);
  $index = random_int(0, $symbol_count - 1);
  $password = substr($symbols, $index , 1);
 
  $password .= chr(random_int(48, 57));
  $password .= chr(random_int(65, 90));
 
  // Add lowercase letters to reach the specified length
  while (strlen($password) < $password_length) {
    $password .= chr(random_int(97, 122));
  }
 
  $password = str_shuffle($password);
  echo $password;
?>

Back