3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'a' => 'food', 'b' => 'foo', 'c' => 'goo', 'd' => 'foo', 'e' => 'good' ]; $needle = 'foo'; $newValue = 'bar'; function array_replace_value(&$ar, $value, $replacement) { $ar = preg_replace('#^' . preg_quote($value) . '$#', $replacement, $ar); } array_replace_value($array, $needle, $newValue); var_export($array);

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)
8.5.30.0150.00319.46
8.5.20.0100.00920.33
8.5.10.0120.00616.88
8.5.00.0140.00820.29
8.4.180.0100.01121.97
8.4.170.0130.00823.83
8.4.160.0170.00923.96
8.4.150.0040.00216.95
8.4.140.0140.00817.41
8.4.130.0050.00418.06
8.4.120.0090.01120.59
8.4.110.0130.00724.06
8.4.100.0150.00617.59
8.4.90.0120.00920.70
8.4.80.0040.00418.82
8.4.70.0060.00219.11
8.4.60.0110.00720.82
8.4.50.0130.00718.80
8.4.40.0170.00317.88
8.4.30.0130.00620.64
8.4.20.0040.00421.66
8.4.10.0470.00017.53
8.3.300.0140.00620.90
8.3.290.0090.01120.76
8.3.280.0110.01018.59
8.3.270.0120.00716.59
8.3.260.0110.00916.59
8.3.250.0120.00618.90
8.3.240.0070.00316.49
8.3.230.0040.00416.53
8.3.220.0160.00218.89
8.3.210.0100.00818.68
8.3.200.0070.00216.86
8.3.190.0100.00916.48
8.3.180.0070.00218.32
8.3.170.0060.01217.04
8.3.160.0110.00718.34
8.3.150.0120.00617.12
8.3.140.0380.00616.32
8.3.130.0250.01416.73
8.3.120.0350.00416.61
8.3.110.0330.00316.55
8.3.100.0300.00916.48
8.3.90.0280.00916.83
8.3.80.0330.01116.39
8.3.70.0420.00616.75
8.3.60.0300.01016.49
8.3.50.0360.00416.78
8.3.40.0370.00617.64
8.3.30.0280.00717.77
8.3.20.0340.00617.43
8.3.10.0300.00617.47
8.3.00.0200.00319.14
8.2.300.0100.01218.33
8.2.290.0120.00716.70
8.2.280.0130.00718.50
8.2.270.0030.00516.91
8.2.260.0280.00916.41
8.2.250.0290.00616.50
8.2.240.0270.00716.31
8.2.230.0230.01316.51
8.2.220.0340.00316.60
8.2.210.0300.00716.43
8.2.200.0310.00616.62
8.2.190.0390.00316.64
8.2.180.0240.01216.48
8.2.170.0280.01217.84
8.2.160.0220.01217.74
8.2.150.0280.01317.77
8.2.140.0340.00617.29
8.2.130.0290.01017.59
8.2.120.0300.00917.40
8.2.110.0320.00717.86
8.2.100.0210.01717.50
8.2.90.0280.00917.80
8.2.80.0230.00817.66
8.2.70.0280.00317.58
8.2.60.0320.01117.56
8.2.50.0370.00017.58
8.2.40.0290.00717.88
8.2.30.0330.00317.44
8.2.20.0290.00717.46
8.2.10.0370.01117.47
8.2.00.0240.01217.62
8.1.340.0130.01217.81
8.1.320.0050.00318.11

preferences:
68.67 ms | 845 KiB | 5 Q