3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Replaces elements from passed arrays into the first array * * array_replace() replaces the values of array1 with values having the * same keys in each of the following arrays. If a key from the first array * exists in the second array, its value will be replaced by the value from * the second array. If the key exists in the second array, and not the * first, it will be created in the first array. If a key only exists in * the first array, it will be left as is. If several arrays are passed for * replacement, they will be processed in order, the later arrays * overwriting the previous values. * * @since PHP 5.3.0 * @param array $array1 The array in which elements are replaced * @param array $array2... The array from which elements will be extracted * @return array Returns an array, or NULL if an error occurs */ function phpcompat_array_replace(array $array1, array $array2 = null) { $args = func_get_args(); $num_args = func_num_args(); if ($num_args < 1) { trigger_error( sprintf('array_replace() expects at least 1 parameter, %d given', $num_args), E_USER_WARNING ); return null; } $res = array(); for ($i = 0; $i < $num_args; ++$i) { if (is_array($args[$i])) { foreach ($args[$i] as $key => $val) { $res[$key] = $val; } } else { trigger_error( sprintf('array_replace(): Argument #%d is not an array', $i + 1), E_USER_WARNING ); return null; } } return $res; } var_dump(array_replace()); var_dump(phpcompat_array_replace());

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.3.60.0080.00816.75
8.3.50.0130.00621.16
8.3.40.0040.01118.88
8.3.30.0060.00918.75
8.3.20.0070.00720.20
8.3.10.0040.00423.48
8.3.00.0030.00619.54
8.2.180.0090.00616.63
8.2.170.0090.00622.96
8.2.160.0100.00520.39
8.2.150.0040.00424.18
8.2.140.0070.00724.66
8.2.130.0040.00426.16
8.2.120.0040.00417.63
8.2.110.0030.00622.27
8.2.100.0080.00417.84
8.2.90.0030.00617.84
8.2.80.0060.00317.97
8.2.70.0040.00417.80
8.2.60.0030.00518.16
8.2.50.0000.00818.10
8.2.40.0000.00720.59
8.2.30.0050.00318.04
8.2.20.0040.00417.73
8.2.10.0000.00818.14
8.2.00.0040.00417.90
8.1.280.0060.00825.92
8.1.270.0190.00020.21
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0200.00022.17
8.1.230.0070.00420.91
8.1.220.0030.00517.74
8.1.210.0040.00418.77
8.1.200.0040.00717.23
8.1.190.0000.00817.23
8.1.180.0050.00318.10
8.1.170.0040.00418.65
8.1.160.0000.00721.94
8.1.150.0000.00718.88
8.1.140.0030.00517.27
8.1.130.0000.00917.65
8.1.120.0070.00017.40
8.1.110.0030.00617.25
8.1.100.0040.00417.38
8.1.90.0000.00817.28
8.1.80.0050.00217.32
8.1.70.0000.00717.32
8.1.60.0030.00517.54
8.1.50.0040.00417.41
8.1.40.0000.00817.48
8.1.30.0040.00417.57
8.1.20.0000.00717.50
8.1.10.0040.00417.45
8.1.00.0000.00717.47
8.0.300.0040.00419.68
8.0.290.0040.00416.58
8.0.280.0000.00718.34
8.0.270.0040.00417.23
8.0.260.0080.00017.29
8.0.250.0040.00416.98
8.0.240.0030.00316.90
8.0.230.0040.00417.03
8.0.220.0040.00416.97
8.0.210.0000.00816.95
8.0.200.0080.00017.02
8.0.190.0040.00416.91
8.0.180.0060.00316.84
8.0.170.0040.00416.89
8.0.160.0050.00216.89
8.0.150.0000.00716.96
8.0.140.0070.00016.85
8.0.130.0000.00513.33
8.0.120.0030.00516.89
8.0.110.0040.00417.00
8.0.100.0070.00016.98
8.0.90.0000.00717.03
8.0.80.0030.01316.92
8.0.70.0040.00416.92
8.0.60.0070.00017.03
8.0.50.0040.00416.81
8.0.30.0040.01317.16
8.0.20.0080.01017.40
8.0.10.0040.00317.02
8.0.00.0100.00816.84
7.4.330.0000.00515.08
7.4.320.0030.00316.43
7.4.300.0000.00616.58
7.4.290.0000.00716.48
7.4.280.0000.00816.49
7.4.270.0070.00016.59
7.4.260.0070.00016.45
7.4.250.0000.00816.56
7.4.240.0070.00016.56
7.4.230.0040.00416.28
7.4.220.0130.00716.51
7.4.210.0070.00716.50
7.4.200.0030.00316.68
7.4.160.0030.01216.63
7.4.150.0100.00717.40
7.4.140.0220.00317.86
7.4.130.0100.00716.43
7.4.120.0120.00816.63
7.4.110.0070.01016.62
7.4.100.0130.00916.50
7.4.90.0110.00716.52
7.4.80.0080.01119.39
7.4.70.0070.01516.53
7.4.60.0030.01316.66
7.4.50.0030.00516.43
7.4.40.0090.00916.46
7.4.30.0120.00416.46
7.4.10.0110.00315.21
7.4.00.0060.00914.98
7.3.330.0000.00613.28
7.3.320.0000.00613.34
7.3.310.0040.00416.34
7.3.300.0000.00716.34
7.3.290.0080.01016.27
7.3.280.0060.01316.33
7.3.270.0070.01017.40
7.3.260.0130.00416.45
7.3.250.0090.00816.36
7.3.240.0070.01016.41
7.3.230.0130.00916.62
7.3.210.0090.00916.64
7.3.200.0090.00616.62
7.3.190.0110.00716.52
7.3.180.0060.01516.51
7.3.170.0140.00316.29
7.3.160.0090.00916.49
7.3.130.0100.01014.92
7.3.120.0060.00914.93
7.3.110.0040.01514.74
7.3.100.0000.01914.79
7.3.90.0080.00814.80
7.3.80.0080.00314.74
7.3.70.0040.00814.88
7.3.60.0090.00614.89
7.3.50.0080.00414.73
7.3.40.0080.00814.88
7.3.30.0040.01114.90
7.3.20.0030.01016.74
7.3.10.0040.01116.64
7.3.00.0100.00316.66
7.2.330.0110.00716.69
7.2.320.0110.00616.64
7.2.310.0160.00616.47
7.2.300.0100.00716.29
7.2.290.0090.00916.27
7.2.260.0130.00615.03
7.2.250.0090.00915.11
7.2.240.0040.01114.51
7.2.230.0060.00914.82
7.2.220.0040.01515.07
7.2.210.0060.00614.73
7.2.200.0040.01214.78
7.2.190.0120.00314.98
7.2.180.0060.00614.98
7.2.170.0070.00714.77
7.2.160.0070.00714.88
7.2.150.0050.00516.73
7.2.140.0030.00916.79
7.2.130.0100.00316.84
7.2.120.0090.00616.91
7.2.110.0000.01516.89
7.2.100.0030.00716.79
7.2.90.0030.01016.49
7.2.80.0060.00616.77
7.2.70.0030.01216.73
7.2.60.0090.00516.68
7.2.50.0060.00316.93
7.2.40.0000.01516.97
7.2.30.0030.00916.49
7.2.20.0000.01116.59
7.2.10.0100.00716.88
7.2.00.0040.00917.92
7.1.330.0070.00715.61
7.1.320.0130.00315.73
7.1.310.0040.01115.61
7.1.300.0060.00615.83
7.1.290.0000.01015.86
7.1.280.0060.00915.57
7.1.270.0000.01015.55
7.1.260.0040.00415.57
7.1.250.0000.01215.70
7.1.240.0080.00415.82
7.1.230.0000.01515.67
7.1.220.0070.00715.56
7.1.210.0030.01015.81
7.1.200.0060.00815.67
7.1.190.0030.01115.79
7.1.180.0030.00615.39
7.1.170.0030.00515.55
7.1.160.0070.00415.81
7.1.150.0030.00915.84
7.1.140.0090.00015.71
7.1.130.0030.00715.77
7.1.120.0090.00015.61
7.1.110.0090.00915.77
7.1.100.0060.00816.87
7.1.90.0060.00915.38
7.1.80.0100.00715.70
7.1.70.0040.00916.11
7.1.60.0070.01217.40
7.1.50.0090.00816.37
7.1.40.0070.00715.70
7.1.30.0100.00315.49
7.1.20.0100.00615.79
7.1.10.0040.01115.75
7.1.00.0020.04419.07
7.0.330.0030.01015.18
7.0.320.0070.00715.25
7.0.310.0030.01015.05
7.0.300.0060.00615.31
7.0.290.0000.01515.30
7.0.280.0080.00315.29
7.0.270.0030.01015.52
7.0.260.0030.01015.36
7.0.250.0040.01115.32
7.0.240.0070.00715.41
7.0.230.0100.00315.06
7.0.220.0130.00615.34
7.0.210.0070.00715.46
7.0.200.0050.00916.04
7.0.190.0040.01115.36
7.0.180.0090.00615.50
7.0.170.0070.00315.11
7.0.160.0090.00415.29
7.0.150.0000.00815.09
7.0.140.0070.01015.09
7.0.130.0040.00715.24
7.0.120.0030.00515.25
7.0.110.0070.00315.39
7.0.100.0030.00915.22
7.0.90.0070.00715.32
7.0.80.0060.00615.30
7.0.70.0000.01315.34
7.0.60.0080.04317.53
7.0.50.0050.03616.49
7.0.40.0120.04216.78
7.0.30.0220.02316.81
7.0.20.0140.04016.71
7.0.10.0040.02216.74
7.0.00.0130.02516.65
5.6.400.0060.00314.09
5.6.390.0030.01014.26
5.6.380.0030.01014.21
5.6.370.0030.01414.37
5.6.360.0000.01013.93
5.6.350.0000.00914.41
5.6.340.0000.00913.79
5.6.330.0070.00314.31
5.6.320.0090.00913.82
5.6.310.0090.00914.45
5.6.300.0030.01014.13
5.6.290.0000.01413.95
5.6.280.0070.03517.38
5.6.270.0040.01114.20
5.6.260.0070.00414.38
5.6.250.0040.00814.33
5.6.240.0090.00914.07
5.6.230.0000.00814.11
5.6.220.0040.01113.87
5.6.210.0100.02717.34
5.6.200.0100.02316.08
5.6.190.0030.02517.31
5.6.180.0070.03717.31
5.6.170.0050.03017.36
5.6.160.0070.04817.27
5.6.150.0080.04016.21
5.6.140.0120.02516.00
5.6.130.0100.05016.26
5.6.120.0090.04217.58
5.6.110.0090.04417.52
5.6.100.0100.02017.50
5.6.90.0090.03517.49
5.6.80.0070.03317.18
5.6.70.2350.02217.26
5.6.60.0000.01214.27
5.6.50.0040.00713.93
5.6.40.0090.00314.07
5.6.30.0030.01313.81
5.6.20.0060.00914.24
5.6.10.0040.00813.93
5.6.00.0000.01513.90
5.5.380.0030.00714.07
5.5.370.0040.00814.03
5.5.360.0090.00613.75
5.5.350.0130.04517.15
5.5.340.0040.03216.02
5.5.330.0070.02517.09
5.5.320.0050.04717.31
5.5.310.0130.02617.22
5.5.300.0050.02416.22
5.5.290.0070.03815.94
5.5.280.0040.03217.31
5.5.270.0060.03917.17
5.5.260.0090.04217.36
5.5.250.0050.03017.26
5.5.240.0100.03817.21
5.5.230.0080.00813.92
5.5.220.0040.00714.13
5.5.210.0080.00413.92
5.5.200.0030.01213.97
5.5.190.0060.00614.11
5.5.180.0070.00313.71
5.5.170.0100.00313.86
5.5.160.0000.01213.95
5.5.150.0040.00414.13
5.5.140.0060.00914.02
5.5.130.0080.00414.16
5.5.120.0070.00714.02
5.5.110.0070.00713.98
5.5.100.0070.00713.78
5.5.90.0080.00313.57
5.5.80.0070.00713.98
5.5.70.0000.01313.72
5.5.60.0030.01013.73
5.5.50.0110.00313.69
5.5.40.0030.01014.25
5.5.30.0040.00414.04
5.5.20.0110.00314.03
5.5.10.0030.01313.93
5.5.00.0060.00913.91
5.4.450.0150.03215.26
5.4.440.0100.02815.32
5.4.430.0120.01815.44
5.4.420.0130.02315.25
5.4.410.0110.01815.23
5.4.400.0130.02315.17
5.4.390.0100.02015.21
5.4.380.0150.01515.15
5.4.370.0080.02315.14
5.4.360.0120.02015.27
5.4.350.0100.02015.20
5.4.340.0140.01815.27
5.4.330.0110.00011.33
5.4.320.0110.02815.10
5.4.310.0120.02015.32
5.4.300.0160.02015.16
5.4.290.0090.02215.07
5.4.280.0070.02315.29
5.4.270.0150.02215.16
5.4.260.0080.02115.32
5.4.250.0110.01815.17
5.4.240.0080.02315.32
5.4.230.0100.02115.28
5.4.220.0110.02015.24
5.4.210.0130.02815.24
5.4.200.0120.03615.09
5.4.190.0030.02915.15
5.4.180.0120.02815.23
5.4.170.0150.03415.19
5.4.160.0070.02515.21
5.4.150.0150.03815.15
5.4.140.0080.02013.85
5.4.130.0070.02113.85
5.4.120.0100.02313.85
5.4.110.0120.02213.95
5.4.100.0060.02013.96
5.4.90.0110.02213.95
5.4.80.0100.02813.81
5.4.70.0130.01713.95
5.4.60.0160.02013.92
5.4.50.0090.02213.94
5.4.40.0090.02713.92
5.4.30.0110.02613.87
5.4.20.0070.02213.90
5.4.10.0100.02013.92
5.4.00.0120.02013.56
5.3.290.0170.03314.63
5.3.280.0170.03714.81
5.3.270.0170.07314.68
5.3.260.0230.05014.59
5.3.250.0230.07014.59
5.3.240.0130.03714.52
5.3.230.0170.07314.50
5.3.220.0100.04014.47
5.3.210.0200.03314.58
5.3.200.0170.08014.64
5.3.190.0270.07014.47
5.3.180.0170.04314.48
5.3.170.0170.03314.68
5.3.160.0100.04014.61
5.3.150.0170.03314.64
5.3.140.0230.04314.79
5.3.130.0230.06714.55
5.3.120.0170.03314.62
5.3.110.0130.04714.57
5.3.100.0230.03713.96
5.3.90.0200.03714.07
5.3.80.0200.03713.93
5.3.70.0270.06313.94
5.3.60.0200.04013.90
5.3.50.0270.04013.82
5.3.40.0200.07013.88
5.3.30.0130.04013.81
5.3.20.0130.05713.78
5.3.10.0170.05313.88
5.3.00.0130.03713.55
5.2.170.0130.02711.20
5.2.160.0200.03311.20
5.2.150.0130.03711.20
5.2.140.0200.03711.06
5.2.130.0270.03011.19
5.2.120.0170.03010.99
5.2.110.0130.03711.19
5.2.100.0070.03311.00
5.2.90.0170.03311.32
5.2.80.0070.03311.02
5.2.70.0100.04311.02
5.2.60.0200.03011.18
5.2.50.0200.04011.04
5.2.40.0070.05310.93
5.2.30.0130.04711.13
5.2.20.0170.03010.96
5.2.10.0070.03310.98
5.2.00.0070.04010.69
5.1.60.0130.02710.08
5.1.50.0070.0279.97
5.1.40.0100.0279.99
5.1.30.0070.03010.34
5.1.20.0130.02310.33
5.1.10.0100.05310.07
5.1.00.0070.0309.96
5.0.50.0030.0279.96
5.0.40.0100.0279.96
5.0.30.0070.0339.96
5.0.20.0030.0379.96
5.0.10.0030.0239.96
5.0.00.0030.0309.96
4.4.90.0030.0179.96
4.4.80.0130.0179.96
4.4.70.0030.0339.96
4.4.60.0170.0279.96
4.4.50.0030.0179.96
4.4.40.0000.0479.96
4.4.30.0070.0139.96
4.4.20.0070.0179.96
4.4.10.0030.0209.96
4.4.00.0070.0239.96
4.3.110.0000.0309.96
4.3.100.0070.0139.96
4.3.90.0030.0209.96
4.3.80.0000.0279.96
4.3.70.0070.0139.96
4.3.60.0030.0179.96
4.3.50.0070.0379.96
4.3.40.0070.0379.96
4.3.30.0000.0179.96
4.3.20.0030.0379.96
4.3.10.0030.0279.96
4.3.00.0000.0209.96

preferences:
63.3 ms | 401 KiB | 5 Q