3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input1 = [ '0' => [ 'foo01' => 'value01', 'bar02' => 'value02', 'formats01' => [ 'subfoo_011' => 'subvalue_011', 'subfoo_012' => 'subvalue_012', ] ], '1' => [ 'foo11' => 'value11', 'bar12' => 'value12', 'formats02' => [ 'subfoo_021' => 'subvalue_021', 'subfoo_022' => 'subvalue_022', ] ] ]; $input2 = [ 'foo' => 'value1', 'bar' => 'value2', 'formats' => [ 'foo' => 'value_1', 'bar' => 'value_2', ] ]; function countValues(array $array) { $i = 0; foreach ($array as $arrayKey => $data) { $i++; $ii = 0; foreach ($data as $key => $value) { $ii++; if (!is_array($value)) { $newArray[':' . $key . '_' . $i . '_' . $ii] = $value; } else if (is_array($value)) { foreach ($value as $subKey => $subValue) { $newArray[':' . $subKey . '_' . $i . '_' . $ii] = $subValue; } } } } return $newArray; } var_dump(countValues($input1)); var_dump(countValues([$input2]));

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.4.20.0170.00318.38
8.4.10.0060.00319.21
8.3.150.0100.00320.63
8.3.140.0080.00016.70
8.3.130.0060.00316.64
8.3.120.0030.01320.59
8.3.110.0080.00016.78
8.3.100.0040.00424.06
8.3.90.0050.00326.77
8.3.80.0030.00717.97
8.3.70.0070.00716.74
8.3.60.0120.00918.30
8.3.50.0100.00717.16
8.3.40.0180.00418.73
8.3.30.0090.00618.88
8.3.20.0030.00618.52
8.3.10.0000.00823.61
8.3.00.0080.00023.65
8.2.260.0060.00919.09
8.2.250.0150.00316.97
8.2.240.0040.00417.37
8.2.230.0040.00420.94
8.2.220.0040.01237.54
8.2.210.0040.00426.77
8.2.200.0080.00416.50
8.2.190.0060.00916.66
8.2.180.0130.01018.05
8.2.170.0060.01022.96
8.2.160.0100.00319.41
8.2.150.0090.00024.18
8.2.140.0070.00324.66
8.2.130.0080.00622.25
8.2.120.0000.00726.35
8.2.110.0050.00522.24
8.2.100.0040.00817.84
8.2.90.0080.00019.34
8.2.80.0040.00417.97
8.2.70.0030.00617.38
8.2.60.0060.00317.89
8.2.50.0030.00618.07
8.2.40.0060.00318.29
8.2.30.0000.00818.03
8.2.20.0040.00418.20
8.2.10.0000.00818.19
8.2.00.0050.00319.49
8.1.310.0090.00916.84
8.1.300.0120.00616.90
8.1.290.0000.00930.84
8.1.280.0030.01425.92
8.1.270.0040.00420.01
8.1.260.0000.00826.35
8.1.250.0070.00028.09
8.1.240.0090.00020.68
8.1.230.0090.00317.70
8.1.220.0050.00317.78
8.1.210.0000.00818.77
8.1.200.0000.00817.23
8.1.190.0000.00917.22
8.1.180.0040.00418.10
8.1.170.0030.00618.66
8.1.160.0070.00018.96
8.1.150.0040.00418.95
8.1.140.0000.00718.82
8.1.130.0060.00320.18
8.1.120.0000.00817.47
8.1.110.0050.00217.36
8.1.100.0040.00417.50
8.1.90.0080.00317.44
8.1.80.0070.00017.50
8.1.70.0070.00417.50
8.1.60.0080.00017.64
8.1.50.0030.00617.54
8.1.40.0070.00317.54
8.1.30.0040.00417.64
8.1.20.0060.00317.63
8.1.10.0040.00417.65
8.1.00.0040.00417.48
8.0.300.0040.00418.77
8.0.290.0040.00416.75
8.0.280.0000.00818.38
8.0.270.0030.00317.27
8.0.260.0030.00318.45
8.0.250.0070.00016.96
8.0.240.0030.00316.87
8.0.230.0030.00316.87
8.0.220.0030.00616.90
8.0.210.0070.00216.91
8.0.200.0000.00816.88
8.0.190.0040.00416.98
8.0.180.0080.00016.90
8.0.170.0040.00416.83
8.0.160.0080.00016.86
8.0.150.0040.00416.81
8.0.140.0080.00016.86
8.0.130.0000.00513.31
8.0.120.0030.00516.86
8.0.110.0080.00016.88
8.0.100.0000.00716.94
8.0.90.0070.00016.97
8.0.80.0080.00916.89
8.0.70.0000.00716.91
8.0.60.0030.00516.74
8.0.50.0050.00216.85
8.0.30.0120.00717.06
8.0.20.0110.01117.40
8.0.10.0050.00216.88
8.0.00.0100.00816.67
7.4.330.0060.00015.55
7.4.320.0030.00316.52
7.4.300.0000.00616.47
7.4.290.0080.00016.63
7.4.280.0040.00416.52
7.4.270.0040.00416.43
7.4.260.0000.00716.60
7.4.250.0030.00516.57
7.4.240.0080.00016.63
7.4.230.0070.00016.60
7.4.220.0050.00316.37
7.4.210.0070.00716.52
7.4.200.0070.00016.44
7.4.160.0090.01016.55
7.4.140.0120.00717.86
7.4.130.0080.00816.58
7.4.120.0090.01416.53
7.4.110.0110.00716.46
7.4.100.0100.01316.51
7.4.90.0130.00616.54
7.4.80.0100.01019.39
7.4.70.0110.00716.51
7.4.60.0170.00616.68
7.4.50.0060.00916.19
7.4.40.0100.00716.51
7.4.00.0070.01015.02
7.3.330.0050.00013.41
7.3.320.0000.00513.35
7.3.310.0000.00716.40
7.3.300.0000.00616.45
7.3.290.0030.00316.42
7.3.280.0100.00716.42
7.3.260.0100.01116.52
7.3.240.0120.00716.45
7.3.230.0050.01116.41
7.3.210.0090.00916.59
7.3.200.0130.00316.45
7.3.190.0150.00416.60
7.3.180.0150.00316.50
7.3.170.0090.01516.61
7.3.160.0070.01016.47
7.3.120.0070.01114.78
7.3.110.0070.01114.91
7.3.100.0060.00914.72
7.3.90.0040.00415.07
7.3.80.0030.00614.89
7.3.70.0080.00414.95
7.3.60.0070.00715.00
7.3.50.0070.00714.81
7.3.40.0030.00614.99
7.3.30.0030.00614.87
7.3.20.0090.00016.50
7.3.10.0070.00716.72
7.3.00.0040.01116.90
7.2.330.0110.00716.75
7.2.320.0120.00616.71
7.2.310.0140.01016.80
7.2.300.0100.01316.60
7.2.290.0100.00716.45
7.2.250.0030.01715.28
7.2.240.0170.00314.86
7.2.230.0130.00315.13
7.2.220.0090.00314.98
7.2.210.0000.01514.81
7.2.200.0030.01215.24
7.2.190.0070.00715.09
7.2.180.0000.01514.67
7.2.170.0030.00914.89
7.2.90.0780.00314.78
7.2.80.0890.00714.81
7.2.70.0650.00614.95
7.2.60.0690.01515.00
7.2.50.0670.00315.03
7.2.40.0550.00815.13
7.2.30.0690.00014.96
7.2.20.0610.01015.18
7.2.10.0780.00314.75
7.2.00.0540.01014.96
7.1.330.0000.01315.90
7.1.320.0040.00715.99
7.1.310.0100.00715.93
7.1.300.0070.00715.80
7.1.290.0060.00615.52
7.1.280.0090.00615.85
7.1.270.0090.00615.83
7.1.260.0100.00315.77
7.1.210.0800.00613.54
7.1.200.0710.00313.99
7.1.190.0740.00313.92
7.1.180.0660.00713.96
7.1.170.0640.00313.74
7.1.160.0800.00613.86
7.1.150.0610.00713.86
7.1.140.0440.01413.88
7.1.130.0640.01113.48
7.1.120.0640.00013.86
7.1.110.0720.00713.73
7.1.100.0840.00714.11
7.1.90.0770.00713.93
7.1.80.0670.00613.82
7.1.70.0550.00913.91
7.1.60.0790.01031.62
7.1.50.0730.01331.59
7.1.40.0710.00931.77
7.1.30.1700.00631.73
7.1.20.0830.01331.71
7.1.10.0730.01013.51
7.1.00.0560.01013.87

preferences:
75.78 ms | 403 KiB | 5 Q