3v4l.org

run code in 300+ PHP versions simultaneously
<?php $inputArray = array( array( array( 'value31', 'value32' ), array( 'value33', 'value34' ), 'value21' ), 'value11' ); function convertArray($inputArray) { if(!checkIfAllArraysExceptLast($inputArray)) return $inputArray; $value = array_pop($inputArray); $result = []; foreach($inputArray as $k => $v){ $result[$k] = is_array($v) ? convertArray($v) : $v; } return [ $value => $result]; } function checkIfAllArraysExceptLast($array){ $v = array_pop($array); return !is_array($v) && count(array_filter($array, fn($v) => is_array($v))) == count($array); } print_r(convertArray($inputArray));

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.10.0000.00923.96
8.3.140.0000.00816.90
8.3.130.0130.00616.82
8.3.120.0090.00218.67
8.3.110.0140.00020.94
8.3.100.0030.00616.61
8.3.90.0040.00418.25
8.3.80.0030.00618.43
8.3.70.0090.00618.55
8.3.60.0110.00620.32
8.3.50.0140.00316.77
8.3.40.0120.00622.14
8.3.30.0070.00720.24
8.3.20.0030.00524.18
8.3.10.0050.00324.66
8.3.00.0040.00426.16
8.2.260.0070.00022.53
8.2.250.0000.00816.95
8.2.240.0090.00619.03
8.2.230.0050.00322.58
8.2.220.0060.00324.06
8.2.210.0070.00726.77
8.2.200.0030.00618.29
8.2.190.0080.00616.58
8.2.180.0140.00418.54
8.2.170.0070.00718.91
8.2.160.0120.00622.96
8.2.150.0040.00425.66
8.2.140.0030.00624.66
8.2.130.0040.00426.16
8.2.120.0090.00017.75
8.2.110.0090.00022.32
8.2.100.0070.00418.03
8.2.90.0030.00618.03
8.2.80.0000.00819.20
8.2.70.0140.00579.33
8.2.60.0140.00479.33
8.2.50.0150.00379.33
8.2.40.0060.01279.33
8.2.30.0120.00579.33
8.2.20.0130.00379.33
8.2.10.0140.00379.33
8.2.00.0140.00279.33
8.1.300.0070.01118.54
8.1.290.0030.00618.88
8.1.280.0130.00625.92
8.1.270.0030.00624.66
8.1.260.0070.00026.35
8.1.250.0070.00028.09
8.1.240.0000.00822.52
8.1.230.0070.00420.89
8.1.220.0000.00817.74
8.1.210.0060.00318.79
8.1.200.0130.00479.33
8.1.190.0120.00679.33
8.1.180.0140.00679.33
8.1.170.0110.00679.33
8.1.160.0140.00779.33
8.1.150.0140.00579.33
8.1.140.0110.00679.33
8.1.130.0110.00779.33
8.1.120.0060.00979.33
8.1.110.0130.00379.33
8.1.100.0120.00579.33
8.1.90.0090.00979.33
8.1.80.0100.00679.33
8.1.70.0130.00379.33
8.1.60.0140.00579.33
8.1.50.0120.00679.33
8.1.40.0130.00379.33
8.1.30.0160.00479.33
8.1.20.0110.00779.33
8.1.10.0160.00479.33
8.1.00.0150.00379.33
8.0.300.0000.00720.08
8.0.290.0100.00779.33
8.0.280.0160.00079.33
8.0.270.0130.00379.33
8.0.260.0000.01679.33
8.0.250.0090.00979.33
8.0.240.0120.00679.33
8.0.230.0090.00979.33
8.0.220.0170.00079.33
8.0.210.0180.00079.33
8.0.200.0150.00379.33
8.0.190.0150.00379.33
8.0.180.0090.00979.33
8.0.170.0130.00379.33
8.0.160.0090.00979.33
8.0.150.0110.00779.33
8.0.140.0200.00379.33
8.0.130.0130.00479.33
8.0.120.0140.00579.33
8.0.110.0120.00679.33
8.0.100.0160.00079.33
8.0.90.0160.00079.33
8.0.80.0100.00779.33
8.0.70.0110.00679.33
8.0.60.0060.01179.33
8.0.50.0160.00079.33
8.0.30.0180.00079.33
8.0.20.0130.00579.33
8.0.10.0120.00679.33

preferences:
52 ms | 403 KiB | 5 Q