3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(-1); $array = array(array('id' => 1, 'fid' => 2), array('id' => 2, 'fid' => 2)); class Map { public static function byProperty(array $array, $property) { $map = array(); foreach ($array as $record) { $propValue = self::_getPropertyValue($record, $property); $map[$propValue][] = $record; } return $map; } public static function byMultiProperty(array $array, array $properties) { $map = array(); $lastProperty = end($property); foreach($array as $record) { $pointer = $map; foreach($properties as $property) { $propValue = self::_getPropertyValue($record, $property); if(!isset($pointer[$propValue])) { $pointer[$propValue] = array(); } $pointer = &$pointer[$propValue]; if($property === $lastProperty) { $pointer[] = $record; } } } return $map; } /** * @param mixed $record * @param string $property * @return mixed */ private static function _getPropertyValue($record, $property) { if (is_array($record)) { return isset($record[$property]) ? $record[$property] : null; } if (is_object($record)) { return isset($record->$property) ? $record->$property : null; } throw new InvalidArgumentException(sprintf('Unsupport record type: %s', gettype($record))); } } var_dump(Map::byMultiProperty($array, array('fid', 'id')));

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.0110.00818.56
8.3.50.0090.01022.83
8.3.40.0090.00618.76
8.3.30.0070.00718.97
8.3.20.0030.00620.29
8.3.10.0040.00421.95
8.3.00.0050.00319.79
8.2.180.0070.01116.75
8.2.170.0070.00722.96
8.2.160.0090.01120.53
8.2.150.0000.00724.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0000.00819.48
8.2.110.0090.00022.24
8.2.100.0070.00419.47
8.2.90.0050.00319.22
8.2.80.0080.00019.21
8.2.70.0040.00417.50
8.2.60.0040.00417.80
8.2.50.0050.00318.07
8.2.40.0040.00418.03
8.2.30.0070.00019.40
8.2.20.0000.00717.75
8.2.10.0050.00318.07
8.2.00.0000.00717.64
8.1.280.0140.00325.92
8.1.270.0040.00421.98
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0090.00024.02
8.1.230.0090.00619.07
8.1.220.0050.00317.76
8.1.210.0080.00018.77
8.1.200.0030.00617.23
8.1.190.0030.00617.53
8.1.180.0000.00818.10
8.1.170.0050.00318.64
8.1.160.0050.00318.72
8.1.150.0040.00418.83
8.1.140.0050.00217.41
8.1.130.0040.00417.85
8.1.120.0000.00717.34
8.1.110.0040.00417.32
8.1.100.0040.00417.34
8.1.90.0000.00717.38
8.1.80.0000.00717.47
8.1.70.0040.00417.41
8.1.60.0000.00817.47
8.1.50.0000.00817.58
8.1.40.0000.00817.45
8.1.30.0000.00917.66
8.1.20.0050.00317.65
8.1.10.0040.00417.43
8.1.00.0040.00417.38
8.0.300.0070.00018.77
8.0.290.0000.00717.18
8.0.280.0070.00018.31
8.0.270.0030.00517.09
8.0.260.0030.00317.20
8.0.250.0030.00416.97
8.0.240.0030.00316.95
8.0.230.0070.00017.02
8.0.220.0070.00016.89
8.0.210.0080.00016.79
8.0.200.0000.00616.95
8.0.190.0000.00917.02
8.0.180.0030.00516.87
8.0.170.0080.00016.98
8.0.160.0040.00417.03
8.0.150.0040.00416.91
8.0.140.0000.00716.87
8.0.130.0030.00313.38
8.0.120.0070.00016.88
8.0.110.0050.00216.84
8.0.100.0070.00016.98
8.0.90.0040.00416.79
8.0.80.0000.01516.94
8.0.70.0040.00416.76
8.0.60.0040.00416.98
8.0.50.0040.00416.97
8.0.30.0060.01316.86
8.0.20.0110.00717.40
8.0.10.0050.00317.05
8.0.00.0080.01016.82
7.4.330.0000.00615.02
7.4.320.0060.00016.52
7.4.300.0040.00416.55
7.4.290.0070.00016.67
7.4.280.0070.00016.53
7.4.270.0050.00516.63
7.4.260.0030.00316.60
7.4.250.0000.00816.43
7.4.240.0070.00016.57
7.4.230.0030.00316.56
7.4.220.0040.01416.67
7.4.210.0070.00716.73
7.4.200.0000.00716.62
7.4.160.0070.01016.52
7.4.150.0090.00917.40
7.4.140.0080.00817.86
7.4.130.0080.01016.64
7.4.120.0070.01116.44
7.4.110.0040.01516.70
7.4.100.0100.00716.62
7.4.90.0060.01116.74
7.4.80.0070.01019.39
7.4.70.0100.00616.41
7.4.60.0060.01016.52
7.4.50.0050.00516.23
7.4.40.0130.00316.56
7.4.30.0080.00816.63
7.4.00.0000.01314.79
7.3.330.0030.00313.41
7.3.320.0020.00213.43
7.3.310.0070.00016.52
7.3.300.0050.00316.44
7.3.290.0070.01016.39
7.3.280.0100.00916.39
7.3.270.0120.00917.40
7.3.260.0090.01316.39
7.3.250.0070.00916.43
7.3.240.0100.00716.27
7.3.230.0100.00716.39
7.3.210.0140.00316.39
7.3.200.0130.01019.39
7.3.190.0070.01016.59
7.3.180.0040.01216.36
7.3.170.0150.00316.58
7.3.160.0060.00916.42
7.3.10.0150.00016.52
7.3.00.0110.00316.64
7.2.330.0070.01116.78
7.2.320.0000.01616.63
7.2.310.0110.00716.68
7.2.300.0080.00816.73
7.2.290.0070.01016.87
7.2.130.0030.01316.95
7.2.120.0060.00416.91
7.2.110.0060.01016.96
7.2.100.0030.01016.91
7.2.90.0040.01116.84
7.2.80.0040.01016.88
7.2.70.0050.00517.01
7.2.60.0060.01016.88
7.2.50.0080.00517.06
7.2.40.0020.01216.84
7.2.30.0050.01017.02
7.2.20.0070.00616.80
7.2.10.0070.00616.79
7.2.00.0020.01117.92
7.1.250.0050.01015.86
7.1.240.0040.00815.76
7.1.230.0090.00015.57
7.1.220.0000.01415.82
7.1.210.0070.00715.47
7.1.200.0040.01015.81
7.1.190.0070.00415.60
7.1.180.0110.00315.64
7.1.170.0060.00915.93
7.1.160.0130.00315.51
7.1.150.0130.00615.71
7.1.140.0060.00615.69
7.1.130.0100.00015.71
7.1.120.0000.01015.91
7.1.110.0070.00715.50
7.1.100.0050.00717.01
7.1.90.0030.01015.80
7.1.80.0120.00315.71
7.1.70.0020.00916.49
7.1.60.0050.01017.64
7.1.50.0060.00816.56
7.1.40.0030.00615.78
7.1.30.0100.00715.44
7.1.20.0040.01115.86
7.1.10.0080.00415.70
7.1.00.0060.04219.10
7.0.330.0040.01115.52
7.0.320.0080.00315.32
7.0.310.0000.01515.38
7.0.300.0030.00715.26
7.0.290.0070.00715.27
7.0.280.0060.01015.48
7.0.270.0100.00315.27
7.0.260.0060.00615.48
7.0.250.0140.00715.52
7.0.240.0100.00315.38
7.0.230.0030.01415.27
7.0.220.0040.01115.24
7.0.210.0070.01015.41
7.0.200.0000.00916.16
7.0.190.0070.00415.45
7.0.180.0080.00415.31
7.0.170.0080.00315.54
7.0.160.0120.00315.52
7.0.150.0070.00715.48
7.0.140.0050.01818.68
7.0.130.0040.00915.52
7.0.120.0030.01015.52
7.0.110.0140.00715.37
7.0.100.0030.00715.16
7.0.90.0130.00315.20
7.0.80.0080.00515.11
7.0.70.0070.00715.44
7.0.60.0100.04317.71
7.0.50.0020.03216.58
7.0.40.0090.02216.88
7.0.30.0150.02116.94
7.0.20.0190.02716.78
7.0.10.0070.04816.92
7.0.00.0040.04916.79
5.6.380.0090.00314.39
5.6.370.0150.00014.43
5.6.360.0100.00614.37
5.6.350.0090.00314.28
5.6.340.0090.00614.53
5.6.330.0060.01014.03
5.6.320.0040.01114.68
5.6.310.0030.01014.64
5.6.300.0030.00914.36
5.6.290.0000.01014.55
5.6.280.0030.04217.76
5.6.270.0150.00014.74
5.6.260.0000.01214.56
5.6.250.0170.00314.83
5.6.240.0030.01314.63
5.6.230.0000.01614.42
5.6.220.0000.01114.38
5.6.210.0100.01817.50
5.6.200.0050.02116.31
5.6.190.0010.02817.71
5.6.180.0100.02417.33
5.6.170.0150.04217.40
5.6.160.0090.01917.45
5.6.150.0050.02316.18
5.6.140.0090.04016.33
5.6.130.0020.03516.14
5.6.120.0150.04217.74
5.6.110.0070.04617.74
5.6.100.0030.04817.75
5.6.90.0090.02817.88
5.6.80.0130.03317.46
5.6.70.0070.01014.18
5.6.60.0060.00614.04
5.6.50.0180.00014.65
5.6.40.0030.01014.28
5.6.30.0030.00814.33
5.6.20.0070.00714.14
5.6.10.0130.00314.02
5.6.00.0100.00314.32
5.5.380.0040.00411.18
5.5.370.0110.00011.23
5.5.360.0000.00711.44
5.5.350.0020.02115.79
5.5.340.0030.04514.59
5.5.330.0050.02215.94
5.5.320.1800.02115.89
5.5.310.0150.03715.68
5.5.300.0040.02214.76
5.5.290.0050.02314.73
5.5.280.0080.02516.04
5.5.270.0090.03016.08
5.5.260.0090.02116.16
5.5.250.0100.01815.94
5.5.240.0020.04615.67
5.5.230.0100.00011.27
5.5.220.0120.00311.25
5.5.210.0040.00711.25
5.5.200.0090.00611.20
5.5.190.0050.00311.18
5.5.180.0000.00711.43
5.5.170.0000.00711.42
5.5.160.0060.00311.39
5.5.150.0090.00911.18
5.5.140.0190.00411.18
5.5.130.0050.00311.27
5.5.120.0030.00511.18
5.5.110.0070.00311.29
5.5.100.0040.01411.36
5.5.90.0080.00611.18
5.5.80.0040.00411.18
5.5.70.0030.00711.18
5.5.60.0110.00411.44
5.5.50.0060.00611.37
5.5.40.0070.00311.22
5.5.30.0000.00911.41
5.5.20.0070.00711.18
5.5.10.0030.00311.40
5.5.00.0100.00711.24
5.4.450.0120.02115.25
5.4.440.0130.03015.33
5.4.430.0120.03215.36
5.4.420.0030.03315.38
5.4.410.0150.02315.10
5.4.400.0110.02814.88
5.4.390.0080.02614.96
5.4.380.0100.02815.06
5.4.370.0100.04014.98
5.4.360.0100.02715.01
5.4.350.0050.02112.52
5.4.340.0030.02212.55
5.4.330.0060.00611.18
5.4.320.0040.02012.74
5.4.310.0120.02012.69
5.4.300.0100.01712.71
5.4.290.0060.02212.81
5.4.280.0050.02212.79
5.4.270.0060.02212.75
5.4.260.0070.02412.85
5.4.250.0030.02812.66
5.4.240.0050.02412.67
5.4.230.0040.02112.64
5.4.220.0040.02812.66
5.4.210.0100.02212.74
5.4.200.0050.02212.64
5.4.190.0070.01912.68
5.4.180.0100.01812.83
5.4.170.0100.01812.76
5.4.160.0070.02012.73
5.4.150.0070.02312.67
5.4.140.0060.02112.69
5.4.130.0050.02212.56
5.4.120.0060.02312.47
5.4.110.0080.01912.48
5.4.100.0070.01812.47
5.4.90.0110.01812.55
5.4.80.0030.02412.46
5.4.70.0070.02212.47
5.4.60.0100.01812.48
5.4.50.0020.02412.47
5.4.40.0110.02112.46
5.4.30.0120.02712.50
5.4.20.0100.01812.60
5.4.10.0070.02212.46
5.4.00.0070.02512.25
5.3.290.0050.02513.00
5.3.280.0100.02812.87
5.3.270.0130.02512.87
5.3.260.0060.02112.92
5.3.250.0100.01912.99
5.3.240.0090.01912.97
5.3.230.0030.02312.89
5.3.220.0090.02112.87
5.3.210.0050.02212.91
5.3.200.0030.02112.90
5.3.190.0040.02312.88
5.3.180.0080.02312.89
5.3.170.0030.02212.91
5.3.160.0030.02212.96
5.3.150.0000.02612.93
5.3.140.0090.01812.87
5.3.130.0060.02312.83
5.3.120.0080.02212.89
5.3.110.0030.02512.95
5.3.100.0050.02612.64
5.3.90.0040.02312.67
5.3.80.0020.02212.65
5.3.70.0050.02212.62
5.3.60.0000.02712.64
5.3.50.0040.02112.57
5.3.40.0080.01712.59
5.3.30.0040.02212.62
5.3.20.0050.02312.46
5.3.10.0100.01812.41
5.3.00.0030.02212.43
5.2.170.0030.01711.25
5.2.160.0030.01811.16
5.2.150.0060.01811.21
5.2.140.0090.01511.13
5.2.130.0040.01711.17
5.2.120.0080.01311.19
5.2.110.0040.01711.23
5.2.100.0030.01711.11
5.2.90.0050.01511.13
5.2.80.0060.01511.20
5.2.70.0020.02111.20
5.2.60.0000.02011.11
5.2.50.0030.01811.12
5.2.40.0050.02011.15
5.2.30.0020.02511.10
5.2.20.0080.01311.11
5.2.10.0030.01811.06
5.2.00.0050.01510.99
5.1.60.0030.01310.58
5.1.50.0030.01610.63
5.1.40.0010.01810.62
5.1.30.0050.01310.74
5.1.20.0010.01610.73
5.1.10.0030.01510.62
5.1.00.0030.01510.65
5.0.50.0030.0109.85
5.0.40.0030.0109.80
5.0.30.0020.0179.77
5.0.20.0020.0149.71
5.0.10.0030.0119.70
5.0.00.0050.0189.66
4.4.90.0020.0118.57
4.4.80.0010.0108.50
4.4.70.0030.0098.49
4.4.60.0000.0138.50
4.4.50.0050.0108.50
4.4.40.0000.0168.52
4.4.30.0030.0088.52
4.4.20.0000.0128.56
4.4.10.0000.0128.58
4.4.00.0050.0108.58
4.3.110.0020.0138.53
4.3.100.0020.0118.48
4.3.90.0030.0078.47
4.3.80.0000.0158.46
4.3.70.0030.0078.46
4.3.60.0010.0098.52
4.3.50.0030.0078.44
4.3.40.0050.0118.42
4.3.30.0010.0097.88
4.3.20.0010.0097.84
4.3.10.0000.0107.85
4.3.00.0020.01013.83

preferences:
52.23 ms | 401 KiB | 5 Q