3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function random_password(int $min, int $max) { $allowed = array_merge( [33, 60, 62, 94, 95], range(48, 57), range(64, 90), range(97, 122) ); $l = random_int($min, $max); $chars = []; while ($l--) { $bi = random_int(0, count($allowed)-1); $chars[] = chr($allowed[$bi]); } return implode('', $chars); } var_dump(random_password(8, 12));
based on thjqC
Output for 7.3.0rc3
string(12) "SwxcrLl9kSVg"
Output for 7.3.0rc2
string(8) "zXlubNgN"
Output for 7.3.0rc1
string(10) "9qNB@uNDMQ"
Output for 7.3.0beta3
string(12) "4JZGzKlceuEL"
Output for 7.3.0beta2
string(12) "lE<xLIN5lwWh"
Output for 7.3.0beta1
string(10) "sh!kbO8p!q"
Output for 7.3.0alpha4
string(8) "lotsl@od"
Output for 7.3.0alpha3
string(9) "8uIbWgo7^"
Output for 7.3.0alpha2
string(12) "vt!ThtxGl9^L"
Output for 7.3.0alpha1
string(12) "IpKOx9jLqeHU"
Output for 7.2.11
string(8) "fIrzz>3^"
Output for 7.2.10
string(8) "c4jzka5u"
Output for 7.2.9
string(11) "b8hs8lbvnAO"
Output for 7.2.8
string(8) "DBtIjWfb"
Output for 7.2.7
string(12) "kG@ft5sqzwzY"
Output for 7.2.6
string(8) "ZGfHKZG9"
Output for 7.2.5
string(11) "4dAv7d63GhO"
Output for 7.2.4
string(10) "<T!PKpX5dw"
Output for 7.2.3
string(11) "DEwjep7cfr0"
Output for 7.2.2
string(11) "7Mf29I<DzPo"
Output for 7.2.1
string(10) "HX<WNAILE_"
Output for 7.2.0
string(8) "WucWNCrL"
Output for 7.1.23
string(9) "RhDkierdn"
Output for 7.1.22
string(12) "rCeRE@iGc!GF"
Output for 7.1.21
string(10) "FuausTMKvQ"
Output for 7.1.20
string(11) "J!qfFaiBc9f"
Output for 7.1.19
string(10) "gUTPbfLr4j"
Output for 7.1.18
string(12) "16<mbqvsh^1q"
Output for 7.1.17
string(10) "huPpGt6JbP"
Output for 7.1.16
string(12) "g7N2NGPvi<j7"
Output for 7.1.15
string(10) "AK_CiH!jjM"
Output for 7.1.14
string(9) "rWWgWOWDX"
Output for 7.1.13
string(8) "0dTaBC6d"
Output for 7.1.12
string(8) "j@^hE8Hl"
Output for 7.1.11
string(10) "N45DmSfgr^"
Output for 7.1.10
string(12) "2aT<nyAbC1g7"
Output for 7.1.9
string(10) "B<dbCx7y5d"
Output for 7.1.8
string(11) "Cq5c3a44RdE"
Output for 7.1.7
string(11) "JfkYNJ6ZYdd"
Output for 7.1.6
string(10) "dl>RsdYCxb"
Output for 7.1.5
string(11) "ueqOTuwW8Ii"
Output for 7.1.4
string(9) "JszVuUsL4"
Output for 7.1.3
string(11) "XYeGlqld7q>"
Output for 7.1.2
string(10) "E5Pa!U_1<>"
Output for 7.1.1
string(9) "wynH8Ffdv"
Output for 7.1.0
string(10) ">4CyUHTSqH"
Output for 7.0.28
string(8) "irJAveE2"
Output for 5.6.38
Catchable fatal error: Argument 1 passed to random_password() must be an instance of int, integer given, called in /in/7D2pL on line 24 and defined in /in/7D2pL on line 3
Process exited with code 255.