3v4l.org

run code in 300+ PHP versions simultaneously
<?php function random_string($charcount = 8, $mode = 0, $capsonly = 0) { /* 0 = alphanumeric 1 = letters only 2 = numbers only */ $chars_alpha_cap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $chars_alpha_low = 'abcdefghijklmnopqrstuvwxyz'; $chars_num = '0123456789'; if ($capsonly) { $chars_alpha_cap = ''; $chars_alpha_low = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; } switch ($mode) { case 1: $chars = $chars_alpha_cap . $chars_alpha_low; break; case 2: $chars = $chars_num; break; default: $chars = $chars_alpha_cap . $chars_alpha_low . $chars_num; } $rand = false; for ($i = 0; $i < $charcount; $i++) { $rand .= $chars[mt_rand(0, strlen($chars) - 1)]; } return $rand; } echo random_string(32,2,1);

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.3.120.0090.00914.52
7.3.110.0100.00514.83
7.3.100.0150.00614.66
7.3.90.0040.01214.83
7.3.80.0110.00414.57
7.3.70.0100.00614.97
7.3.60.0080.00814.67
7.3.50.0150.00814.48
7.3.40.0120.00814.75
7.3.30.0090.01214.82
7.3.20.0130.00616.73
7.3.10.0710.00014.89
7.3.00.0050.01216.60
7.2.240.0150.00415.14
7.2.230.0070.01014.91
7.2.220.0150.00315.16
7.2.210.0100.00314.91
7.2.200.0110.00515.01
7.2.190.0100.01415.10
7.2.180.0140.00715.32
7.2.170.0130.00614.96
7.2.160.0100.01015.07
7.2.150.0070.01116.43
7.2.140.0070.01116.89
7.2.130.0220.00516.85
7.2.120.0070.01316.93
7.2.110.0060.01216.92
7.2.100.0610.00415.03
7.2.90.0050.01516.82
7.2.80.0030.01716.99
7.2.70.0110.00716.94
7.2.60.0030.01416.48
7.2.50.0110.00716.91
7.2.40.0070.00416.98
7.2.30.0070.00716.83
7.2.20.0060.00616.81
7.2.10.0040.01516.91
7.2.00.0050.00818.21
7.1.330.0400.00913.88
7.1.320.0430.01713.96
7.1.310.0180.00915.54
7.1.300.0070.01015.55
7.1.290.0120.00415.85
7.1.280.0130.00815.73
7.1.270.0030.01315.81
7.1.260.0090.01115.66
7.1.250.0040.01315.96
7.1.70.0030.00516.84
7.1.60.0110.01419.70
7.1.50.0090.01517.02
7.1.00.0030.07722.46
7.0.200.0000.00716.96
7.0.140.0100.06722.01
7.0.100.0400.08719.89
7.0.90.0200.04019.87
7.0.80.0130.06719.95
7.0.70.0170.07719.97
7.0.60.0100.06719.84
7.0.50.0200.06320.26
7.0.40.0070.08319.99
7.0.30.0100.03720.05
7.0.20.0030.06019.98
7.0.10.0170.04719.89
7.0.00.0100.04019.90
5.6.280.0070.07021.03
5.6.250.0070.08020.44
5.6.240.0070.05020.53
5.6.230.0070.04320.57
5.6.220.0030.06320.60
5.6.210.0070.07020.61
5.6.200.0100.04720.98
5.6.190.0030.04320.95
5.6.180.0130.04021.02
5.6.170.0100.08321.09
5.6.160.0030.08021.08
5.6.150.0030.06020.90
5.6.140.0170.08320.97
5.6.130.0170.06721.01
5.6.120.0070.06020.87
5.6.110.0000.06720.95
5.6.100.0130.08021.11
5.6.90.0070.08720.95
5.6.80.0070.04020.51
5.6.70.0000.04320.29
5.6.60.0070.03320.29
5.6.50.0130.07320.45
5.6.40.0030.04720.38
5.6.30.0100.03320.39
5.6.20.0000.04320.32
5.6.10.0030.04020.41
5.6.00.0030.04320.38
5.5.380.0030.05720.31
5.5.370.0100.07320.30
5.5.360.0030.06720.40
5.5.350.0070.08320.32
5.5.340.0130.06320.79
5.5.330.0070.06720.84
5.5.320.0070.05720.82
5.5.310.0000.08320.87
5.5.300.0070.07020.85
5.5.290.0030.06720.82
5.5.280.0030.08320.59
5.5.270.0100.05020.77
5.5.260.0030.04720.86
5.5.250.0070.05020.41
5.5.240.0030.04020.08
5.5.230.0070.03720.16
5.5.220.0100.03320.12
5.5.210.0070.07320.16
5.5.200.0030.04019.95
5.5.190.0070.04020.17
5.5.180.0000.04320.21
5.5.160.0100.03720.17
5.5.150.0100.03720.10
5.5.140.0070.04720.17
5.5.130.0030.03020.10
5.5.120.0030.03720.09
5.5.110.0070.04020.14
5.5.100.0100.03020.00
5.5.90.0030.03319.91
5.5.80.0030.03720.07
5.5.70.0030.04320.03
5.5.60.0030.03320.05
5.5.50.0070.02720.03
5.5.40.0100.03020.01
5.5.30.0030.03720.01
5.5.20.0070.03320.00
5.5.10.0030.03319.97
5.5.00.0100.04319.92
5.4.450.0070.07719.45
5.4.440.0170.07319.40
5.4.430.0130.06719.48
5.4.420.0030.04719.53
5.4.410.0100.05019.23
5.4.400.0130.03019.21
5.4.390.0070.03719.03
5.4.380.0030.03719.18
5.4.370.0000.03319.16
5.4.360.0030.03719.13
5.4.350.0070.04019.23
5.4.340.0030.04319.13
5.4.320.0000.04719.16
5.4.310.0030.04018.85
5.4.300.0070.03719.23
5.4.290.0130.03018.90
5.4.280.0030.03019.02
5.4.270.0000.04318.84
5.4.260.0130.02719.23
5.4.250.0030.03719.13
5.4.240.0030.03318.86
5.4.230.0100.02719.19
5.4.220.0070.03319.03
5.4.210.0000.03318.90
5.4.200.0030.03019.17
5.4.190.0000.03718.93
5.4.180.0000.04019.11
5.4.170.0100.04318.86
5.4.160.0070.04719.21
5.4.150.0070.03719.10
5.4.140.0070.06316.38
5.4.130.0000.04716.13
5.4.120.0000.04316.39
5.4.110.0030.05716.34
5.4.100.0070.03716.44
5.4.90.0000.05016.41
5.4.80.0030.07016.41
5.4.70.0000.03716.49
5.4.60.0130.05716.36
5.4.50.0000.04316.46
5.4.40.0030.05316.39
5.4.30.0030.06716.39
5.4.20.0030.07316.30
5.4.10.0100.05016.50
5.4.00.0100.06315.80
5.3.290.0100.03014.64
5.3.280.0130.03014.62
5.3.270.0030.04314.63
5.3.260.0000.04314.67
5.3.250.0030.03714.62
5.3.240.0070.03314.59
5.3.230.0100.03314.52
5.3.220.0030.03714.70
5.3.210.0000.04014.56
5.3.200.0000.03714.59
5.3.190.0000.03714.58
5.3.180.0000.04014.55
5.3.170.0000.05314.62
5.3.160.0130.07314.62
5.3.150.0000.06314.66
5.3.140.0070.05314.63
5.3.130.0030.07014.52
5.3.120.0030.06314.67
5.3.110.0030.07714.68
5.3.100.0100.06314.00
5.3.90.0130.05714.02
5.3.80.0070.05714.07
5.3.70.0100.05314.14
5.3.60.0030.05714.01
5.3.50.0000.04313.95
5.3.40.0100.07013.97
5.3.30.0030.07313.84
5.3.20.0030.07013.67
5.3.10.0000.03713.75
5.3.00.0070.03313.65
5.2.170.0030.04011.13
5.2.160.0070.06011.06
5.2.150.0100.03711.13
5.2.140.0070.03011.16
5.2.130.0100.02311.18
5.2.120.0000.03311.18
5.2.110.0030.03311.19
5.2.100.0000.03011.11
5.2.90.0030.02711.16
5.2.80.0030.03311.11
5.2.70.0100.03311.18
5.2.60.0030.03710.91
5.2.50.0070.06011.04
5.2.40.0000.03311.11
5.2.30.0000.06710.85
5.2.20.0070.02711.01
5.2.10.0030.02310.89
5.2.00.0000.05710.86
5.1.60.0100.04010.03
5.1.50.0000.0279.98
5.1.40.0000.0309.98
5.1.30.0000.03710.25
5.1.20.0100.04710.48
5.1.10.0000.0439.91
5.1.00.0000.02710.20
5.0.50.0000.0238.64
5.0.40.0000.0238.43
5.0.30.0000.0538.30
5.0.20.0030.0438.22
5.0.10.0030.0208.25
5.0.00.0030.0438.01
4.4.90.0070.0136.71
4.4.80.0030.0206.71
4.4.70.0000.0176.71
4.4.60.0000.0176.71
4.4.50.0070.0136.71
4.4.40.0030.0506.71
4.4.30.0030.0136.71
4.4.20.0070.0206.71
4.4.10.0070.0176.71
4.4.00.0000.0306.71
4.3.110.0000.0236.71
4.3.100.0030.0206.71
4.3.90.0030.0276.71
4.3.80.0070.0506.71
4.3.70.0000.0206.71
4.3.60.0000.0206.71
4.3.50.0000.0336.71
4.3.40.0100.0306.71
4.3.30.0000.0276.71
4.3.20.0030.0206.71
4.3.10.0000.0236.71
4.3.00.0000.0406.71

preferences:
39.06 ms | 401 KiB | 5 Q