3v4l.org

run code in 300+ PHP versions simultaneously
<?php function insert_random_chars($str, $alphabet = "ABCDEFGHIJKLMNOPGRSTUVWXYZ") { // An array to hold the result $result = array(); // The highest character index in the string $max = strlen($alphabet) - 1; // Loop the characters in the input string foreach (str_split($str, 1) as $char) { // Add the current character and a random character to the output array array_push($result, $char, $alphabet[mt_rand(0, $max)]; } // Join the output array together return implode('', $result); } echo insert_random_chars("0123456789");

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)
5.4.210.0100.04812.38
5.4.200.0130.04512.38
5.4.190.0150.04312.38
5.4.180.0150.05112.38
5.4.170.0150.05212.38
5.4.160.0180.06312.38
5.4.150.0130.04712.37
5.4.140.0120.04912.07
5.4.130.0130.03812.04
5.4.120.0110.04112.01
5.4.110.0120.03812.01
5.4.100.0190.03412.01
5.4.90.0140.04412.01
5.4.80.0090.04512.01
5.4.70.0160.04112.00
5.4.60.0100.04512.01
5.4.50.0210.04812.00
5.4.40.0130.04311.99
5.4.30.0120.03811.99
5.4.20.0130.03711.99
5.4.10.0110.04511.99
5.4.00.0090.04111.48
5.3.270.0130.05112.73
5.3.260.0150.05412.72
5.3.250.0150.04512.72
5.3.240.0130.05112.72
5.3.230.0130.04612.71
5.3.220.0120.04312.68
5.3.210.0120.04812.68
5.3.200.0240.04512.68
5.3.190.0160.04012.68
5.3.180.0180.04912.68
5.3.170.0100.04112.67
5.3.160.0120.04312.67
5.3.150.0130.04212.67
5.3.140.0130.03912.66
5.3.130.0120.04312.66
5.3.120.0100.05112.66
5.3.110.0120.04512.66
5.3.100.0130.04812.12
5.3.90.0160.05312.08
5.3.80.0100.04312.07
5.3.70.0080.05012.07
5.3.60.0120.04512.06
5.3.50.0120.04512.00
5.3.40.0150.04812.00
5.3.30.0150.04411.96
5.3.20.0190.05311.74
5.3.10.0130.04311.71
5.3.00.0160.04211.69

preferences:
142.29 ms | 1398 KiB | 7 Q