3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Arrayable { public function toArray(); } class Item implements Arrayable { protected $attributes = array(); protected $someParameter = true; public function __construct($attributes) { $this->attributes = $attributes; } public function toArray() { return $this->attributes; } public function __toArray() { return $this->toArray(); } } class ItemCollection implements Arrayable { protected $items = array(); public function addItem(Item $item) { $this->items[] = $item; } public function toArray() { $result = array(); foreach ($this->items as $item) { $result[] = $item->toArray(); } return $result; } public function __toArray() { return $this->toArray(); } } $array = array('foo' => 'bar', 'baz' => 'qux'); $item = new Item($array); print_r((array) $item); print_r($item->toArray()); $collection = new ItemCollection(); $collection->addItem($item); $collection->addItem($item); print_r((array) $collection); print_r($collection->toArray());

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.0090.00618.31
8.3.50.0090.01121.20
8.3.40.0060.01518.73
8.3.30.0110.00419.22
8.3.20.0090.00020.02
8.3.10.0050.00321.86
8.3.00.0040.00419.25
8.2.180.0070.01116.63
8.2.170.0170.00022.96
8.2.160.0030.01020.57
8.2.150.0080.00024.18
8.2.140.0030.00524.66
8.2.130.0000.00826.16
8.2.120.0070.00022.21
8.2.110.0090.00022.11
8.2.100.0060.00617.75
8.2.90.0050.00319.20
8.2.80.0050.00317.97
8.2.70.0090.00017.50
8.2.60.0050.00318.05
8.2.50.0040.00418.07
8.2.40.0050.00318.34
8.2.30.0030.00518.18
8.2.20.0040.00417.80
8.2.10.0040.00418.07
8.2.00.0030.00517.74
8.1.280.0100.00725.92
8.1.270.0040.00423.80
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0060.00323.96
8.1.230.0080.00420.94
8.1.220.0040.00417.74
8.1.210.0060.00318.77
8.1.200.0030.00617.11
8.1.190.0040.00417.23
8.1.180.0000.00818.10
8.1.170.0000.01018.66
8.1.160.0000.00722.04
8.1.150.0000.00718.94
8.1.140.0020.00517.46
8.1.130.0000.00717.69
8.1.120.0050.00317.40
8.1.110.0000.00717.45
8.1.100.0030.00517.51
8.1.90.0050.00317.39
8.1.80.0070.00017.37
8.1.70.0000.00717.33
8.1.60.0100.00017.55
8.1.50.0000.01017.56
8.1.40.0060.00317.52
8.1.30.0040.00417.71
8.1.20.0060.00317.56
8.1.10.0080.00017.62
8.1.00.0000.00817.38
8.0.300.0050.00218.77
8.0.290.0040.00416.75
8.0.280.0040.00418.46
8.0.270.0030.00317.27
8.0.260.0000.00617.20
8.0.250.0000.00716.95
8.0.240.0030.00316.92
8.0.230.0000.00716.94
8.0.220.0000.00716.95
8.0.210.0000.00716.92
8.0.200.0040.00416.86
8.0.190.0040.00416.92
8.0.180.0000.00816.88
8.0.170.0050.00317.05
8.0.160.0040.00416.92
8.0.150.0000.00716.85
8.0.140.0080.00016.87
8.0.130.0000.00613.43
8.0.120.0000.00816.94
8.0.110.0000.00716.96
8.0.100.0080.00017.02
8.0.90.0000.00716.91
8.0.80.0060.01016.95
8.0.70.0050.00316.79
8.0.60.0040.00417.03
8.0.50.0000.00817.00
8.0.30.0130.01017.09
8.0.20.0120.01417.40
8.0.10.0080.00016.96
8.0.00.0120.00616.79
7.4.330.0020.00515.02
7.4.320.0000.00716.51
7.4.300.0030.00316.61
7.4.290.0000.00716.51
7.4.280.0050.00316.50
7.4.270.0030.00316.66
7.4.260.0030.00316.56
7.4.250.0080.00016.47
7.4.240.0030.00416.49
7.4.230.0070.00016.51
7.4.220.0060.01316.58
7.4.210.0000.01416.53
7.4.200.0000.00716.70
7.4.160.0060.00916.53
7.4.150.0030.01617.40
7.4.140.0060.01417.86
7.4.130.0090.01416.46
7.4.120.0080.01116.51
7.4.110.0120.00616.50
7.4.100.0030.01316.57
7.4.90.0180.00016.57
7.4.80.0140.00419.39
7.4.70.0100.00916.48
7.4.60.0070.01016.36
7.4.50.0000.00616.64
7.4.40.0100.00616.42
7.4.30.0060.01016.52
7.4.00.0090.00715.01
7.3.330.0000.00813.40
7.3.320.0000.00613.33
7.3.310.0000.00716.36
7.3.300.0000.00716.20
7.3.290.0070.00916.33
7.3.280.0020.01316.32
7.3.270.0120.00917.40
7.3.260.0190.00016.44
7.3.250.0090.00816.61
7.3.240.0030.01716.40
7.3.230.0040.01316.46
7.3.210.0100.00716.61
7.3.200.0160.00619.39
7.3.190.0130.01016.60
7.3.180.0000.01616.66
7.3.170.0080.00816.32
7.3.160.0080.00816.30
7.3.120.0000.01814.46
7.3.110.0070.01015.11
7.3.100.0060.00614.95
7.3.90.0090.00614.64
7.3.80.0040.00814.68
7.3.70.0060.00914.96
7.3.60.0090.00614.54
7.3.50.0000.01215.00
7.3.40.0000.01414.56
7.3.30.0030.01014.79
7.3.20.0060.00916.57
7.3.10.0030.01416.78
7.3.00.0070.01016.62
7.2.330.0120.01216.81
7.2.320.0150.00816.71
7.2.310.0080.01116.81
7.2.300.0030.01516.86
7.2.290.0070.01816.66
7.2.250.0030.01615.04
7.2.240.0070.01315.34
7.2.230.0070.00715.07
7.2.220.0040.00814.68
7.2.210.0090.00314.98
7.2.200.0070.01014.88
7.2.190.0060.01115.23
7.2.180.0080.00814.79
7.2.170.0060.00914.88
7.2.60.0090.00616.30
7.2.00.0060.01019.49
7.1.330.0110.00316.02
7.1.320.0000.01115.66
7.1.310.0110.00415.68
7.1.300.0060.00615.89
7.1.290.0070.00715.66
7.1.280.0040.01215.61
7.1.270.0100.00315.66
7.1.260.0100.00715.76
7.1.200.0030.00615.65
7.1.100.0060.00318.05
7.1.70.0000.00717.20
7.1.60.0080.00419.32
7.1.50.0190.01934.95
7.1.00.0100.07022.57
7.0.200.0060.00316.90
7.0.140.0070.07022.01
7.0.60.0130.07719.86
7.0.50.0100.03717.93
7.0.40.0030.04320.11
7.0.30.0300.08020.07
7.0.20.0130.05020.05
7.0.10.0070.09020.20
7.0.00.0000.04720.10
5.6.280.0100.07021.08
5.6.210.0030.04320.52
5.6.200.0070.04018.29
5.6.190.0100.08020.47
5.6.180.0230.08020.55
5.6.170.0130.05720.71
5.6.160.0030.04320.48
5.6.150.0030.08018.18
5.6.140.0030.04018.28
5.6.130.0130.08018.15
5.6.120.0130.04321.01
5.6.110.0030.09721.14
5.6.100.0100.03720.89
5.6.90.0070.08321.02
5.6.80.0100.07320.39
5.6.70.4170.04020.26
5.5.350.0330.03720.45
5.5.340.0130.07718.01
5.5.330.0070.06020.19
5.5.320.0330.06020.27
5.5.310.0230.08020.41
5.5.300.0000.07318.04
5.5.290.0130.08017.97
5.5.280.0070.06320.82
5.5.270.0130.06020.85
5.5.260.0070.04020.77
5.5.250.0170.07720.60
5.5.240.0270.07020.28
5.4.450.0870.06319.56
5.4.440.1030.05319.48
5.4.430.0500.07319.62
5.4.420.0730.08019.46
5.4.410.0830.04719.34
5.4.400.1200.07019.30
5.4.390.0900.06019.29
5.4.380.1070.04719.14
5.4.370.0530.06719.29
5.4.360.0670.06319.29
5.4.350.0670.06019.16
5.4.340.0030.03912.02
5.4.320.0050.04012.52
5.4.310.0060.04012.51
5.4.300.0060.03812.51
5.4.290.0100.03612.50
5.4.280.0080.03512.41
5.4.270.0100.03712.40
5.4.260.0100.04312.41
5.4.250.0110.03412.41
5.4.240.0060.04012.41
5.4.230.0140.03112.40
5.4.220.0050.03812.40
5.4.210.0050.03712.39
5.4.200.0090.03612.39
5.4.190.0070.04112.39
5.4.180.0050.04112.39
5.4.170.0140.04312.40
5.4.160.0080.04012.41
5.4.150.0110.03812.40
5.4.140.0070.03812.09
5.4.130.0040.03812.07
5.4.120.0060.03512.03
5.4.110.0070.03412.02
5.4.100.0060.03612.02
5.4.90.0090.03812.03
5.4.80.0060.03912.02
5.4.70.0050.03612.02
5.4.60.0120.02912.02
5.4.50.0090.03312.02
5.4.40.0080.03312.01
5.4.30.0100.03612.00
5.4.20.0060.03712.00
5.4.10.0050.03712.00
5.4.00.0080.03511.49
5.3.290.0070.04012.80
5.3.280.0060.04112.70
5.3.270.0080.03812.73
5.3.260.0080.03812.71
5.3.250.0080.03812.72
5.3.240.0050.03912.72
5.3.230.0050.03912.71
5.3.220.0090.03612.68
5.3.210.0050.04112.68
5.3.200.0040.03912.68
5.3.190.0060.03912.67
5.3.180.0090.03812.68
5.3.170.0140.03012.67
5.3.160.0040.03912.67
5.3.150.0080.03612.67
5.3.140.0070.03712.66
5.3.130.0100.04212.66
5.3.120.0100.03512.66
5.3.110.0080.03812.66
5.3.100.0030.04012.13
5.3.90.0070.03612.12
5.3.80.0080.03512.10
5.3.70.0070.03612.10
5.3.60.0060.03712.09
5.3.50.0060.03712.04
5.3.40.0110.03212.04
5.3.30.0100.03112.00
5.3.20.0090.03211.78
5.3.10.0100.03111.74
5.3.00.0070.03511.73
5.2.170.0080.0299.23
5.2.160.0080.0289.23
5.2.150.0080.0289.23
5.2.140.0050.0319.23
5.2.130.0070.0289.19
5.2.120.0060.0399.19
5.2.110.0070.0309.20
5.2.100.0040.0319.19
5.2.90.0060.0309.19
5.2.80.0080.0289.19
5.2.70.0040.0329.19
5.2.60.0070.0299.14
5.2.50.0100.0379.11
5.2.40.0040.0319.09
5.2.30.0050.0309.06
5.2.20.0040.0309.06
5.2.10.0040.0308.96
5.2.00.0050.0298.82
5.1.60.0040.0258.11
5.1.50.0080.0228.11
5.1.40.0050.0258.08
5.1.30.0070.0258.43
5.1.20.0100.0228.46
5.1.10.0050.0318.19
5.1.00.0070.0278.18
5.0.50.0060.0206.65
5.0.40.0050.0196.52
5.0.30.0030.0386.33
5.0.20.0050.0186.30
5.0.10.0030.0216.28
5.0.00.0030.0336.27
4.4.90.0010.0204.78
4.4.80.0030.0154.75
4.4.70.0030.0154.76
4.4.60.0030.0154.75
4.4.50.0020.0164.77
4.4.40.0030.0244.70
4.4.30.0050.0134.76
4.4.20.0040.0194.84
4.4.10.0050.0134.84
4.4.00.0020.0274.76
4.3.110.0020.0174.67
4.3.100.0020.0154.67
4.3.90.0030.0144.64
4.3.80.0040.0264.58
4.3.70.0040.0134.63
4.3.60.0020.0154.63
4.3.50.0030.0154.62
4.3.40.0020.0244.54
4.3.30.0010.0163.29
4.3.20.0000.0183.26
4.3.10.0040.0133.22
4.3.00.0070.0277.00

preferences:
28.73 ms | 401 KiB | 5 Q