3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getArrayFromHyphenArray($flatArray){ $deepArray = array(); foreach($flatArray as $key => $value){ $keysArray = explode('-', $key); $deepArray = recursiveSet($deepArray, $keysArray, $value); } } function recursiveSet(&$array, &$arg, $value){ static $count = 0; if(empty($arg)){ $array = $value; return $array; } $key = array_shift($arg); if(!isset($array[$key])){ print_r($key); $count++; echo $count; $array[$key] = array(); } return recursiveSet($array[$key],$arg,$value); } $flatArray = array('this-is-something' => 'value1', 'bif-is-else' => 'value3', 'this-different-else' => 'value2'); print_r(getArrayFromHyphenArray($flatArray));

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.00718.68
8.3.50.0070.01016.49
8.3.40.0040.01118.70
8.3.30.0000.01418.71
8.3.20.0000.00720.39
8.3.10.0060.00321.94
8.3.00.0080.00023.75
8.2.180.0150.00618.41
8.2.170.0070.01022.96
8.2.160.0110.00420.43
8.2.150.0000.00824.18
8.2.140.0000.00824.66
8.2.130.0000.00820.75
8.2.120.0030.00526.35
8.2.110.0040.00419.29
8.2.100.0110.00018.05
8.2.90.0000.00819.36
8.2.80.0050.00317.97
8.2.70.0000.00817.63
8.2.60.0060.00319.66
8.2.50.0000.00818.09
8.2.40.0080.00022.19
8.2.30.0080.00019.58
8.2.20.0000.00717.70
8.2.10.0040.00418.13
8.2.00.0000.00718.04
8.1.280.0080.00825.92
8.1.270.0130.00722.02
8.1.260.0100.00028.09
8.1.250.0040.00428.09
8.1.240.0000.01022.52
8.1.230.0120.00017.77
8.1.220.0040.00417.79
8.1.210.0000.00818.77
8.1.200.0030.00617.48
8.1.190.0050.00317.22
8.1.180.0030.00518.10
8.1.170.0080.00018.59
8.1.160.0040.00420.79
8.1.150.0040.00418.96
8.1.140.0000.00919.59
8.1.130.0000.00717.63
8.1.120.0000.00717.45
8.1.110.0050.00217.53
8.1.100.0040.00417.47
8.1.90.0060.00317.48
8.1.80.0070.00017.52
8.1.70.0000.00717.49
8.1.60.0060.00317.62
8.1.50.0050.00317.54
8.1.40.0070.00617.36
8.1.30.0080.00017.60
8.1.20.0000.00717.48
8.1.10.0090.00017.49
8.1.00.0040.00417.48
8.0.300.0040.00418.77
8.0.290.0050.00216.75
8.0.280.0040.00418.46
8.0.270.0030.00517.39
8.0.260.0040.00417.21
8.0.250.0040.00417.03
8.0.240.0000.00817.00
8.0.230.0000.00817.09
8.0.220.0000.00716.99
8.0.210.0030.00317.00
8.0.200.0000.00616.90
8.0.190.0040.00717.05
8.0.180.0030.00516.85
8.0.170.0000.00716.90
8.0.160.0000.00716.97
8.0.150.0040.00716.81
8.0.140.0000.00817.00
8.0.130.0000.00613.44
8.0.120.0000.00816.85
8.0.110.0000.00716.88
8.0.100.0030.00516.97
8.0.90.0040.00416.92
8.0.80.0040.01116.93
8.0.70.0000.00816.93
8.0.60.0000.00816.92
8.0.50.0040.00416.84
8.0.30.0140.00916.92
8.0.20.0060.01617.40
8.0.10.0000.00816.96
8.0.00.0060.01216.71
7.4.330.0020.00216.67
7.4.320.0070.00016.59
7.4.300.0000.00816.63
7.4.290.0030.00316.53
7.4.280.0000.00716.51
7.4.270.0030.00316.51
7.4.260.0000.00716.52
7.4.250.0000.00716.54
7.4.240.0000.00816.62
7.4.230.0030.00516.40
7.4.220.0070.03016.60
7.4.210.0110.00416.60
7.4.200.0070.00016.62
7.4.160.0090.00916.59
7.4.150.0150.01117.40
7.4.140.0070.01317.86
7.4.130.0050.01316.61
7.4.120.0140.00316.56
7.4.110.0140.00316.59
7.4.100.0050.01116.39
7.4.90.0120.00516.61
7.4.80.0100.00919.39
7.4.70.0040.01916.55
7.4.60.0040.01416.40
7.4.50.0090.00616.28
7.4.40.0090.00916.67
7.4.30.0120.00916.72
7.4.00.0130.00315.05
7.3.330.0060.00013.27
7.3.320.0030.00313.46
7.3.310.0000.00616.45
7.3.300.0030.00316.41
7.3.290.0060.01116.44
7.3.280.0100.00816.46
7.3.270.0100.00717.40
7.3.260.0060.01416.56
7.3.250.0090.00916.47
7.3.240.0080.00916.46
7.3.230.0030.01316.46
7.3.210.0100.00716.40
7.3.200.0110.00619.39
7.3.190.0110.00516.50
7.3.180.0090.00716.47
7.3.170.0040.01216.43
7.3.160.0040.01216.44
7.3.10.0070.00716.43
7.3.00.0030.00716.39
7.2.330.0120.00616.86
7.2.320.0100.01016.87
7.2.310.0080.00816.63
7.2.300.0120.00416.48
7.2.290.0120.00416.84
7.2.130.0120.00616.39
7.2.120.0110.01116.66
7.2.110.0100.00916.50
7.2.100.0060.01316.43
7.2.90.0060.00916.76
7.2.80.0040.01416.49
7.2.70.0230.00316.50
7.2.60.0130.00616.54
7.2.50.0140.00916.69
7.2.40.0200.01016.50
7.2.30.0190.00616.45
7.2.20.0080.00816.47
7.2.10.0060.01116.63
7.2.00.0100.00718.01
7.1.250.0040.01315.54
7.1.200.0030.00615.65
7.1.100.0000.01017.88
7.1.70.0000.00816.92
7.1.60.0100.01419.40
7.1.50.0100.01016.98
7.1.00.0030.07722.54
7.0.200.0000.00916.47
7.0.60.0200.03721.77
7.0.50.0030.06017.78
7.0.40.0130.05720.30
7.0.30.0270.05020.16
7.0.20.0170.06720.12
7.0.10.0130.06020.21
7.0.00.0030.08720.10
5.6.280.0030.03321.03
5.6.210.0000.04320.57
5.6.200.0100.05018.14
5.6.190.0070.09020.34
5.6.180.0330.07020.61
5.6.170.0200.07720.56
5.6.160.0070.08320.46
5.6.150.0170.07018.27
5.6.140.0130.07318.14
5.6.130.0000.06718.27
5.6.120.0100.08021.02
5.6.110.0100.08021.05
5.6.100.0170.07720.99
5.6.90.0030.08721.01
5.6.80.0100.08020.41
5.5.350.0100.03720.50
5.5.340.0030.04717.99
5.5.330.0030.04320.19
5.5.320.0270.07720.19
5.5.310.0330.06320.35
5.5.300.0070.05717.98
5.5.290.0100.08018.08
5.5.280.0100.07720.88
5.5.270.0100.08320.76
5.5.260.0030.04020.96
5.5.250.0070.05320.67
5.5.240.0170.04720.36

preferences:
41.97 ms | 401 KiB | 5 Q