3v4l.org

run code in 300+ PHP versions simultaneously
<?php $structure = [ "1" => [ 'id' => '1', 'username' => 'username', 'children' => [ [ 'id' => '-1', 'username' => 'NULL', 'children' => [ [ 'id' => '-1', 'username' => 'NULL', 'children' => [ [ 'id' => '-1', 'username' => 'NULL', 'children' => [], ], ], ], ], ], ], ], ]; $entry = [ 157 => [ 'id' => '157', 'username' => 'test1', 'children' => [ [ 'id' => '158', 'username' => 'test1', 'children' => [ [ 'id' => '159', 'username' => 'test2', 'children' => [ [ 'id' => '160', 'username' => 'test3', 'children' => [], ], [ 'id' => '160', 'username' => 'KICK ME BECAUSE I M NOT EXIST IN FIRST ARRAY', 'children' => [], ], ], ], ], ], [ 'id' => '160', 'username' => 'KICK ME BECAUSE I M NOT EXIST IN FIRST ARRAY', 'children' => [ [ 'id' => '159', 'username' => 'KICK ME BECAUSE I M NOT EXIST IN FIRST ARRAY', 'children' => [ [ 'id' => '161', 'username' => 'KICK ME BECAUSE I M NOT EXIST IN FIRST ARRAY', 'children' => [], ], ], ], ], ], ], ], ]; function truncateRecursive($structure, $entry) { $output = []; while (($structureKey = key($structure)) !== null && ($entryKey = key($entry)) !== null) { $output[$entryKey] = !is_array($entry[$entryKey]) ? $entry[$entryKey] : truncateRecursive($structure[$structureKey], $entry[$entryKey]); unset($structure[$structureKey], $entry[$entryKey]); } return $output; } var_export(truncateRecursive($structure, $entry));

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.0070.01319.36
8.4.10.0040.00420.55
8.3.150.0040.01519.00
8.3.140.0120.00616.48
8.3.130.0080.00018.53
8.3.120.0090.00020.84
8.3.110.0000.01020.94
8.3.100.0030.00618.43
8.3.90.0080.00326.77
8.3.80.0030.00619.36
8.3.70.0040.01416.75
8.3.60.0090.00916.63
8.3.50.0120.00523.64
8.3.40.0100.00719.40
8.3.30.0110.00418.64
8.3.20.0040.00424.18
8.3.10.0080.00024.66
8.3.00.0050.00326.16
8.2.270.0090.00916.60
8.2.260.0080.00020.06
8.2.250.0040.01118.59
8.2.240.0030.00618.84
8.2.230.0090.00022.58
8.2.220.0040.00437.54
8.2.210.0070.00026.77
8.2.200.0090.00018.88
8.2.190.0150.00716.88
8.2.180.0140.00625.92
8.2.170.0100.00622.96
8.2.160.0030.01422.96
8.2.150.0080.00025.66
8.2.140.0070.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00426.35
8.2.110.0060.00621.09
8.2.100.0090.00318.03
8.2.90.0040.00417.88
8.2.80.0040.00418.97
8.2.70.0000.00917.50
8.2.60.0000.00817.63
8.2.50.0000.00818.05
8.2.40.0000.00818.22
8.2.30.0050.00218.09
8.2.20.0000.00718.27
8.2.10.0070.00019.33
8.2.00.0000.00719.34
8.1.310.0070.01018.44
8.1.300.0090.00018.07
8.1.290.0070.00330.84
8.1.280.0110.00425.92
8.1.270.0050.00323.99
8.1.260.0050.00328.09
8.1.250.0080.00028.09
8.1.240.0070.00322.11
8.1.230.0060.00620.90
8.1.220.0050.00317.74
8.1.210.0030.00518.77
8.1.200.0000.00817.35
8.1.190.0000.00817.35
8.1.180.0000.00818.10
8.1.170.0030.00618.59
8.1.160.0040.00418.84
8.1.150.0040.00418.92
8.1.140.0000.00718.82
8.1.130.0000.00720.12
8.1.120.0000.00717.56
8.1.110.0000.00717.50
8.1.100.0040.00417.40
8.1.90.0070.00417.45
8.1.80.0070.00017.38
8.1.70.0030.00317.36
8.1.60.0000.00817.64
8.1.50.0030.00617.43
8.1.40.0030.00617.47
8.1.30.0040.00417.67
8.1.20.0060.00317.64
8.1.10.0040.00417.44
8.1.00.0040.00417.54
8.0.300.0000.00718.77
8.0.290.0040.00416.63
8.0.280.0050.00218.33
8.0.270.0070.00318.05
8.0.260.0030.00318.35
8.0.250.0000.00717.02
8.0.240.0070.00017.03
8.0.230.0030.00317.02
8.0.220.0000.00816.80
8.0.210.0000.00716.81
8.0.200.0000.00816.88
8.0.190.0060.00316.92
8.0.180.0000.00816.97
8.0.170.0030.00616.98
8.0.160.0040.00416.97
8.0.150.0000.00716.85
8.0.140.0000.00716.84
8.0.130.0030.00313.34
8.0.120.0080.00016.94
8.0.110.0000.00816.96
8.0.100.0040.00416.82
8.0.90.0080.00016.81
8.0.80.0040.01116.94
8.0.70.0050.00316.91
8.0.60.0040.00416.79
8.0.50.0070.00016.95
8.0.30.0100.00617.10
8.0.20.0100.00917.19
8.0.10.0040.00416.84
8.0.00.0090.00916.77
7.4.330.0000.00615.55
7.4.320.0040.00416.57
7.4.300.0030.00516.61
7.4.290.0000.00816.52
7.4.280.0080.00016.67
7.4.270.0030.00316.55
7.4.260.0050.00013.42
7.4.250.0030.00316.59
7.4.240.0000.00716.62
7.4.230.0030.00316.73
7.4.220.0040.00416.47
7.4.210.0050.00916.57
7.4.200.0000.00716.48
7.4.130.0080.01316.71
7.4.120.0090.00916.65
7.4.110.0120.00616.54
7.4.100.0200.00316.46
7.4.90.0120.00616.62
7.4.80.0050.01319.39
7.4.70.0030.01916.59
7.4.60.0100.00716.51
7.4.50.0040.01316.39
7.4.40.0110.01116.32
7.4.30.0190.00516.22
7.4.20.0080.01516.51
7.4.10.0100.01016.51
7.4.00.0100.00716.77
7.3.330.0000.00716.49
7.3.320.0060.00013.21
7.3.310.0070.00016.28
7.3.300.0020.00516.36
7.3.290.0070.00816.38
7.3.280.0030.01116.38
7.3.260.0130.00716.55
7.3.240.0080.00916.51
7.3.230.0170.00716.28
7.3.210.0200.00516.30
7.3.200.0130.00316.41
7.3.190.0140.00416.52
7.3.180.0000.01716.32
7.3.170.0180.00416.37
7.3.160.0120.00916.63
7.3.150.0040.01716.32
7.3.140.0080.01216.34
7.3.130.0080.01116.68
7.3.120.0040.01516.51
7.3.110.0110.00916.39
7.3.100.0120.00916.33
7.3.90.0100.01016.54
7.3.80.0130.00816.37
7.3.70.0160.00716.45
7.3.60.0200.00016.34
7.3.50.0130.01016.25
7.3.40.0150.00816.36
7.3.30.0130.00716.38
7.3.20.0170.00716.41
7.3.10.0140.00816.34
7.3.00.0090.01316.35
7.2.330.0100.01016.50
7.2.320.0110.00616.75
7.2.310.0060.01016.68
7.2.300.0070.01016.64
7.2.290.0150.00616.82
7.2.280.0130.00916.78
7.2.270.0080.01316.48
7.2.260.0060.01316.36
7.2.250.0080.01216.57
7.2.240.0150.00616.77
7.2.230.0220.00016.83
7.2.220.0000.02016.51
7.2.210.0140.01116.28
7.2.200.0080.01216.70
7.2.190.0120.01216.66
7.2.180.0140.01016.50
7.2.170.0110.00816.55
7.2.160.0080.01216.73
7.2.150.0140.01116.66
7.2.140.0090.01316.56
7.2.130.0180.00516.65
7.2.120.0120.00716.57
7.2.110.0190.00316.39
7.2.100.0230.00316.69
7.2.90.0110.00716.75
7.2.80.0100.01016.62
7.2.70.0150.00316.62
7.2.60.0120.00916.67
7.2.50.0120.01116.82
7.2.40.0190.00316.62
7.2.30.0090.01416.79
7.2.20.0170.00316.56
7.2.10.0110.01116.60
7.2.00.0130.00516.59

preferences:
26.4 ms | 403 KiB | 5 Q