3v4l.org

run code in 300+ PHP versions simultaneously
<?php function randomPassword() { $currentmonth = date('n'); $alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ"; $random = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789"; $pass = array(); $alphaLength = strlen($random) - 1; for ($i = 0; $i < 5; $i++) { $n = rand(0, $alphaLength); $pass[] = $random[$n]; } $pass[4] = substr($alphabet, $currentmonth - 1, 1); return implode($pass); } echo randomPassword();

preferences:
26.86 ms | 407 KiB | 5 Q