php generate password


<?php
/**
  * make a password with less a digital number, upper alpha char and lower alpha char 
  * @param int $length
  * @return string
  */
public function getPassword($length = 10)
{
    if ($length < 3) {
        $length = 4;
    }
    $password = str_random($length - 3);
    $alpha = "abcdefghijkmnprstuvwxyz";
    $digital = "2345678";
    $password_char_ary = [
        'alpha_lower' => strtolower($alpha),
        'digital' => $digital,
        'alpha_upper' => strtoupper($alpha),
    ];
    $count = count($password_char_ary);
    while ($count > 0) {
        srand(date('YmdHis' . $count));
        $str = array_shift($password_char_ary);
        $str_count = strlen($str) - 1;
        $str_position = rand(0, $str_count);
        $password_count = strlen($password);
        $position = rand(0, $password_count);
        $replace = $str[$str_position];
        $password = substr_replace($password, $replace, $position, 0);
        $count = count($password_char_ary);
    }
    return $password;
}

留言