3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array(0, 1, 2); foreach ($arr as &$v) { $v += 1; } foreach ($arr as $v) { var_dump($v); } /* Output: int(1) int(2) int(2) Lines 2-4 iterate over $arr by reference. So, when we reach line 5, $v is still a reference to last element of the array (e.g. $v = &$arr[2]). There are only 2 possible ways to "unlink" $v from the array element: - use unset(): unset($v); - make $v a reference to another value: $v = &$x; Since $v is reference to last element of the array, the foreach loop in lines 5-7 will execute like this: 1) $v = $arr[0]; $arr is now [1, 2, 1], since writing to $v updates $arr[2] 2) $v = $arr[1]; $arr is now [1, 2, 2], since writing to $v updates $arr[2] 3) $v = $arr[2]; This causes self-assignment (e.g. $arr[2] = $arr[2]), which doesn't change the value of $arr. */

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.0150.00618.56
8.3.50.0060.00918.33
8.3.40.0110.00418.75
8.3.30.0170.00318.34
8.3.20.0000.00720.53
8.3.10.0110.00322.02
8.3.00.0090.00922.48
8.2.180.0090.00618.13
8.2.170.0090.00619.08
8.2.160.0070.00722.96
8.2.150.0070.00025.66
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00421.18
8.2.110.0000.00920.35
8.2.100.0040.00718.03
8.2.90.0080.00017.84
8.2.80.0040.00417.97
8.2.70.0000.00817.63
8.2.60.0090.00018.22
8.2.50.0000.00818.10
8.2.40.0040.00419.51
8.2.30.0000.00818.21
8.2.20.0030.00618.16
8.2.10.0040.00419.55
8.2.00.0040.00419.37
8.1.280.0110.00425.92
8.1.270.0040.00424.66
8.1.260.0040.01126.35
8.1.250.0040.00428.09
8.1.240.0030.00622.46
8.1.230.0060.00622.66
8.1.220.0050.00317.79
8.1.210.0040.00418.77
8.1.200.0030.00617.36
8.1.190.0000.00817.23
8.1.180.0080.00018.10
8.1.170.0050.00318.25
8.1.160.0000.00818.89
8.1.150.0000.00718.87
8.1.140.0040.00421.97
8.1.130.0030.00317.36
8.1.120.0050.00417.36
8.1.110.0040.00417.49
8.1.100.0030.00617.45
8.1.90.0060.00317.46
8.1.80.0050.00317.53
8.1.70.0080.00317.44
8.1.60.0000.00917.43
8.1.50.0030.00517.54
8.1.40.0060.00317.56
8.1.30.0090.00517.57
8.1.20.0120.00417.66
8.1.10.0120.00417.40
8.1.00.0140.00317.34
8.0.300.0040.00420.03
8.0.290.0000.00916.63
8.0.280.0040.00418.44
8.0.270.0040.00416.81
8.0.260.0080.00016.77
8.0.250.0070.00016.93
8.0.240.0050.00516.96
8.0.230.0000.00716.84
8.0.220.0040.00416.88
8.0.210.0070.00016.95
8.0.200.0030.00317.04
8.0.190.0040.00416.91
8.0.180.0060.00316.91
8.0.170.0090.00016.85
8.0.160.0080.00616.90
8.0.150.0120.00116.73
8.0.140.0100.00516.73
8.0.130.0080.00515.07
8.0.120.0080.00516.84
8.0.110.0110.00216.76
8.0.100.0120.00216.83
8.0.90.0070.00716.85
8.0.80.0130.00716.86
8.0.70.0060.00816.75
8.0.60.0080.00616.84
8.0.50.0080.00516.69
8.0.30.0130.00717.02
8.0.20.0110.00816.93
8.0.10.0070.00716.97
8.0.00.0110.00916.79
7.4.330.0020.00215.55
7.4.320.0000.00716.60
7.4.300.0030.00316.47
7.4.290.0070.00016.42
7.4.280.0030.00516.49
7.4.270.0060.00416.57
7.4.260.0070.00514.89
7.4.250.0100.00416.42
7.4.240.0060.00716.49
7.4.230.0120.00216.52
7.4.220.0050.00516.53
7.4.210.0100.00516.53
7.4.200.0080.00316.53
7.4.190.0140.00316.57
7.4.180.0130.00616.61
7.4.160.0110.00316.54
7.4.150.0140.00316.61
7.4.140.0160.00016.34
7.4.130.0100.01116.37
7.4.120.0060.00916.27
7.4.110.0100.00516.42
7.4.100.0040.01216.29
7.4.90.0080.00816.43
7.4.80.0120.00617.27
7.4.70.0090.00716.40
7.4.60.0090.00816.39
7.4.50.0080.00616.33
7.4.40.0100.00816.32
7.4.30.0150.00416.32
7.4.20.0120.00516.40
7.4.10.0090.00716.38
7.4.00.0080.00815.95
7.3.330.0110.00216.12
7.3.320.0100.00314.68
7.3.310.0110.00416.13
7.3.300.0120.00216.24
7.3.290.0080.00416.19
7.3.280.0090.01116.20
7.3.270.0180.00016.20
7.3.260.0120.00916.38
7.3.250.0150.00516.31
7.3.240.0080.00916.29
7.3.230.0140.00516.33
7.3.220.0120.00716.23
7.3.210.0110.00716.38
7.3.200.0120.00516.26
7.3.190.0120.00616.23
7.3.180.0100.00916.36
7.3.170.0110.00716.37
7.3.160.0110.00816.32
7.3.150.0100.00716.41
7.3.140.0090.00816.27
7.3.130.0100.00716.31
7.3.120.0100.00716.03
7.3.110.0080.00915.93
7.3.100.0090.00715.65
7.3.90.0080.00815.63
7.3.80.0090.00815.64
7.3.70.0100.00715.60
7.3.60.0080.00815.59
7.3.50.0080.00915.61
7.3.40.0110.00515.55
7.3.30.0090.00715.60
7.3.20.0130.00716.46
7.3.10.0100.00716.36
7.3.00.0110.00616.37
7.2.340.0170.00316.40
7.2.330.0120.00816.43
7.2.320.0110.00716.48
7.2.310.0130.00616.42
7.2.300.0120.00716.46
7.2.290.0120.00816.35
7.2.280.0090.01016.41
7.2.270.0100.00916.39
7.2.260.0110.00816.47
7.2.250.0100.00816.18
7.2.240.0090.01116.11
7.2.230.0090.00815.75
7.2.220.0090.00715.83
7.2.210.0100.00715.83
7.2.200.0080.00915.76
7.2.190.0090.00915.73
7.2.180.0080.00915.84
7.2.170.0090.00915.80
7.2.160.0090.00715.77
7.2.150.0100.00816.63
7.2.140.0110.00616.64
7.2.130.0090.00816.71
7.2.120.0100.00816.55
7.2.110.0110.00816.62
7.2.100.0100.00816.61
7.2.90.0100.00916.69
7.2.80.0100.00816.49
7.2.70.0110.00916.58
7.2.60.0120.00916.59
7.2.50.0100.01016.61
7.2.40.0100.00816.74
7.2.30.0140.00516.73
7.2.20.0080.01016.59
7.2.10.0090.00916.69
7.2.00.0130.00416.61
7.1.330.0190.00615.95
7.1.320.0130.00715.60
7.1.310.0110.00715.65
7.1.300.0160.00715.63
7.1.290.0130.00815.54
7.1.280.0100.00915.64
7.1.270.0080.01115.54
7.1.260.0130.00715.56
7.1.250.0110.00815.49
7.1.240.0110.00915.91
7.1.230.0130.00815.88
7.1.220.0120.00915.77
7.1.210.0140.00615.85
7.1.200.0140.00715.89
7.1.190.0130.00615.82
7.1.180.0120.00815.86
7.1.170.0150.00415.96
7.1.160.0170.00715.76
7.1.150.0130.00715.78
7.1.140.0130.00815.86
7.1.130.0110.00715.86
7.1.120.0110.00815.87
7.1.110.0110.00915.85
7.1.100.0160.00715.89
7.1.90.0110.00815.97
7.1.80.0110.00815.90
7.1.70.0110.00815.76
7.1.60.0110.00915.87
7.1.50.0130.00715.93
7.1.40.0120.00715.86
7.1.30.0150.00515.86
7.1.20.0110.01115.94
7.1.10.0120.00915.82
7.1.00.0140.00815.84

preferences:
59.58 ms | 401 KiB | 5 Q