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(); foreach($array as $record) { $pointer = $map; foreach($properties as $property) { $propValue = self::_getPropertyValue($record, $property); if(!isset($pointer[$propValue])) { $pointer[$propValue] = array(); } $pointer[$propValue][] = $property; $pointer = &$pointer[$propValue]; } } 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.0140.00018.43
8.3.50.0130.00722.93
8.3.40.0110.00418.93
8.3.30.0090.00518.89
8.3.20.0000.00920.05
8.3.10.0080.00021.69
8.3.00.0040.00419.68
8.2.180.0090.01216.63
8.2.170.0090.00622.96
8.2.160.0110.00720.53
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0000.00826.16
8.2.120.0060.00321.12
8.2.110.0100.00019.27
8.2.100.0130.00317.75
8.2.90.0050.00319.22
8.2.80.0030.00519.38
8.2.70.0000.00917.63
8.2.60.0080.00018.05
8.2.50.0000.00818.07
8.2.40.0030.00518.15
8.2.30.0040.00419.39
8.2.20.0080.00017.84
8.2.10.0040.00418.06
8.2.00.0040.00417.77
8.1.280.0130.00725.92
8.1.270.0040.00422.20
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00323.99
8.1.230.0060.00620.75
8.1.220.0040.00418.77
8.1.210.0090.00319.09
8.1.200.0030.00617.35
8.1.190.0000.00817.53
8.1.180.0030.00618.10
8.1.170.0000.00918.39
8.1.160.0050.00318.79
8.1.150.0040.00418.92
8.1.140.0000.00817.39
8.1.130.0070.00017.84
8.1.120.0040.00417.43
8.1.110.0050.00217.47
8.1.100.0000.00717.46
8.1.90.0070.00017.38
8.1.80.0070.00017.49
8.1.70.0040.00417.42
8.1.60.0000.00817.55
8.1.50.0040.00417.41
8.1.40.0080.00017.55
8.1.30.0040.00417.75
8.1.20.0040.00417.64
8.1.10.0040.00417.43
8.1.00.0050.00317.52
8.0.300.0040.00320.04
8.0.290.0050.00316.93
8.0.280.0040.00418.47
8.0.270.0030.00317.30
8.0.260.0030.00317.17
8.0.250.0000.00716.95
8.0.240.0070.00016.90
8.0.230.0040.00417.02
8.0.220.0030.00316.91
8.0.210.0000.00716.84
8.0.200.0030.00317.00
8.0.190.0000.00717.01
8.0.180.0040.00416.93
8.0.170.0000.00916.83
8.0.160.0040.00416.89
8.0.150.0020.00516.93
8.0.140.0070.00016.80
8.0.130.0030.00313.29
8.0.120.0000.00716.80
8.0.110.0000.00716.82
8.0.100.0040.00416.98
8.0.90.0040.00416.96
8.0.80.0000.01616.98
8.0.70.0000.00716.74
8.0.60.0000.00816.89
8.0.50.0000.00716.79
8.0.30.0080.01117.06
8.0.20.0080.01217.40
8.0.10.0020.00517.10
8.0.00.0080.01316.66
7.4.330.0050.00015.14
7.4.320.0000.00616.54
7.4.300.0000.00716.55
7.4.290.0030.00316.62
7.4.280.0000.00716.43
7.4.270.0000.00716.53
7.4.260.0050.00216.66
7.4.250.0000.00716.39
7.4.240.0000.00716.62
7.4.230.0030.00316.61
7.4.220.0160.00716.70
7.4.210.0150.00016.66
7.4.200.0000.00716.52
7.4.160.0120.00416.60
7.4.150.0080.01117.40
7.4.140.0090.01217.86
7.4.130.0090.00716.53
7.4.120.0080.01216.66
7.4.110.0100.00716.74
7.4.100.0060.01116.45
7.4.90.0030.01316.61
7.4.80.0140.00719.39
7.4.70.0090.00916.44
7.4.60.0070.01116.29
7.4.50.0000.00716.46
7.4.40.0100.00716.29
7.4.30.0120.00916.62
7.4.00.0090.00014.94
7.3.330.0000.00713.33
7.3.320.0030.00313.23
7.3.310.0050.00216.31
7.3.300.0070.00016.38
7.3.290.0100.00916.37
7.3.280.0080.00916.33
7.3.270.0110.00717.40
7.3.260.0040.01316.60
7.3.250.0110.00916.42
7.3.240.0040.01316.34
7.3.230.0120.00616.58
7.3.210.0100.01016.38
7.3.200.0100.00919.39
7.3.190.0040.01816.43
7.3.180.0130.00316.34
7.3.170.0120.00916.63
7.3.160.0000.01516.36
7.2.330.0090.00916.93
7.2.320.0100.00616.67
7.2.310.0120.00916.85
7.2.300.0090.00616.46
7.2.290.0080.01416.66
7.2.00.0000.01419.51
7.1.100.0030.01017.87
7.1.70.0070.00717.09
7.1.60.0070.00719.34
7.1.50.0070.01416.78
7.1.00.0100.07022.36
7.0.200.0030.00516.82
7.0.140.0030.07021.99
7.0.100.0400.06719.91
7.0.90.0070.08019.92
7.0.80.0070.08319.87
7.0.70.0070.08019.87
7.0.60.0170.07020.05
7.0.50.0170.06720.31
7.0.40.0130.07720.16
7.0.30.0130.03720.06
7.0.20.0170.04320.10
7.0.10.0170.08020.05
7.0.00.0100.08720.07
5.6.280.0100.06720.87
5.6.250.0030.05020.64
5.6.240.0070.08020.77
5.6.230.0100.07720.68
5.6.220.0000.09020.50
5.6.210.0070.05020.68
5.6.200.0130.07321.07
5.6.190.0100.06321.07
5.6.180.0170.07321.04
5.6.170.0100.07721.07
5.6.160.0100.07721.07
5.6.150.0100.07321.18
5.6.140.0100.07720.96
5.6.130.0170.08021.02
5.6.120.0170.08321.06
5.6.110.0000.05721.04
5.6.100.0100.08721.17
5.6.90.0070.08721.10
5.6.80.0030.07320.50
5.6.70.0070.08320.48
5.6.60.0130.07320.45
5.6.50.0130.07320.50
5.6.40.0030.06720.54
5.6.30.0030.04320.52
5.6.20.0100.03720.29
5.6.10.0070.03720.42
5.6.00.0070.04020.31
5.5.380.0100.07020.58
5.5.370.0130.07720.58
5.5.360.0230.07720.40
5.5.350.0030.08020.48
5.5.340.0130.06320.91
5.5.330.0100.07720.66
5.5.320.0130.08020.91
5.5.310.0070.08020.87
5.5.300.0030.05320.93
5.5.290.0170.07320.88
5.5.280.0000.08720.90
5.5.270.0070.07720.77
5.5.260.0100.07720.93
5.5.250.0100.07320.59
5.5.240.0100.08320.30
5.5.230.0070.07020.27
5.5.220.0200.07020.25
5.5.210.0000.08720.20
5.5.200.0030.08320.17
5.5.190.0030.04020.10
5.5.180.0000.04320.22
5.5.160.0030.04020.19
5.5.150.0070.03720.13
5.5.140.0030.03720.23
5.5.130.0030.04320.09
5.5.120.0030.03720.22
5.5.110.0030.05020.29
5.5.100.0070.05020.09
5.5.90.0070.04020.05
5.5.80.0170.06720.03
5.5.70.0070.04020.16
5.5.60.0070.06020.01
5.5.50.0030.05319.97
5.5.40.0070.04720.06
5.5.30.0030.04020.09
5.5.20.0100.06019.99
5.5.10.0070.04020.05
5.5.00.0070.03719.98
5.4.450.0100.07719.56
5.4.440.0130.05319.15
5.4.430.0130.07019.32
5.4.420.0070.06319.36
5.4.410.0070.04719.34
5.4.400.0170.03318.91
5.4.390.0030.04019.13
5.4.380.0100.07019.17
5.4.370.0000.08318.91
5.4.360.0100.06319.21
5.4.350.0000.05718.95
5.4.340.0070.03719.05
5.4.320.0030.03719.13
5.4.310.0030.03719.03
5.4.300.0030.04019.21
5.4.290.0000.04019.13
5.4.280.0070.04018.88
5.4.270.0070.03719.04
5.4.260.0030.04718.85
5.4.250.0100.03018.87
5.4.240.0070.05719.08
5.4.230.0030.04319.12
5.4.220.0130.04319.23
5.4.210.0070.04719.18
5.4.200.0100.03718.94
5.4.190.0030.03718.89
5.4.180.0000.04719.13
5.4.170.0030.03719.12
5.4.160.0030.03719.03
5.4.150.0030.04019.07
5.4.140.0070.03316.45
5.4.130.0030.03316.41
5.4.120.0070.03316.25
5.4.110.0030.04016.47
5.4.100.0030.03716.50
5.4.90.0030.03716.52
5.4.80.0030.03316.41
5.4.70.0000.06316.38
5.4.60.0130.05316.49
5.4.50.0000.04316.41
5.4.40.0070.03316.50
5.4.30.0000.03716.49
5.4.20.0070.03016.46
5.4.10.0000.04716.48
5.4.00.0000.05315.81
5.3.290.0030.04014.67
5.3.280.0070.03014.59
5.3.270.0100.05714.68
5.3.260.0000.04014.57
5.3.250.0070.04014.64
5.3.240.0030.03714.71
5.3.230.0000.04014.66
5.3.220.0000.04014.70
5.3.210.0030.04014.56
5.3.200.0000.04014.64
5.3.190.0000.04014.59
5.3.180.0070.03714.51
5.3.170.0070.03714.67
5.3.160.0000.04314.61
5.3.150.0000.04014.60
5.3.140.0000.04014.66
5.3.130.0070.03714.51
5.3.120.0030.03714.50
5.3.110.0070.03314.70
5.3.100.0000.04014.17
5.3.90.0000.04014.10
5.3.80.0070.03313.94
5.3.70.0100.03014.13
5.3.60.0130.02713.94
5.3.50.0030.03714.09
5.3.40.0000.04314.10
5.3.30.0030.03313.84
5.3.20.0000.03713.64
5.3.10.0030.05313.70
5.3.00.0070.05013.59
5.2.170.0030.03011.09
5.2.160.0030.02711.02
5.2.150.0030.03011.09
5.2.140.0000.03711.22
5.2.130.0030.02711.14
5.2.120.0030.03311.25
5.2.110.0000.05011.18
5.2.100.0100.03311.21
5.2.90.0000.03711.13
5.2.80.0030.04011.03
5.2.70.0030.06311.03
5.2.60.0000.06310.98
5.2.50.0030.06011.10
5.2.40.0030.04310.95
5.2.30.0030.06011.12
5.2.20.0030.06011.07
5.2.10.0070.03010.93
5.2.00.0000.05010.80
5.1.60.0030.04010.07
5.1.50.0070.0379.89
5.1.40.0070.0439.82
5.1.30.0000.05010.44
5.1.20.0070.05010.43
5.1.10.0030.0509.97
5.1.00.0070.04710.12
5.0.50.0100.0408.63
5.0.40.0000.0278.43
5.0.30.0000.0638.38
5.0.20.0100.0378.38
5.0.10.0000.0438.38
5.0.00.0000.0578.38
4.4.90.0070.0308.38
4.4.80.0030.0208.38
4.4.70.0070.0338.38
4.4.60.0000.0378.38
4.4.50.0100.0308.38
4.4.40.0000.0538.38
4.4.30.0000.0238.38
4.4.20.0030.0208.38
4.4.10.0000.0408.38
4.4.00.0070.0438.38
4.3.110.0000.0178.38
4.3.100.0070.0178.38
4.3.90.0000.0378.38
4.3.80.0030.0538.38
4.3.70.0000.0238.38
4.3.60.0000.0338.38
4.3.50.0000.0278.38
4.3.40.0030.0308.38
4.3.30.0000.0278.38
4.3.20.0000.0308.38
4.3.10.0000.0338.38
4.3.00.0070.0178.38

preferences:
51.95 ms | 401 KiB | 5 Q