3v4l.org

run code in 300+ PHP versions simultaneously
<?php function find_parent($ar, $id='id', $pid='pid') { foreach($ar as $v) $t[$v[$id]] = $v; foreach ($t as $k => $item){ if( $item[$pid] ){ if( ! isset($t[$item[$pid]]['parent'][$item[$pid]]) ) $t[$item[$id]]['parent'][$item[$pid]] =& $t[$item[$pid]]; } } return $t; } function find_child($ar, $id='id', $pid='pid') { foreach($ar as $v) $t[$v[$id]] = $v; foreach ($t as $k => $item){ if( $item[$pid] ) { $t[$item[$pid]]['child'][$item[$id]] =& $t[$k]; } } return $t; } $data = array( array('ID'=>1, 'PARENT'=>0, 'NAME'=>'祖父'), array('ID'=>2, 'PARENT'=>1, 'NAME'=>'父亲'), array('ID'=>3, 'PARENT'=>1, 'NAME'=>'叔伯'), array('ID'=>4, 'PARENT'=>2, 'NAME'=>'自己'), array('ID'=>5, 'PARENT'=>4, 'NAME'=>'儿子'), ); $p = find_parent($data, 'ID', 'PARENT'); $c = find_child($data, 'ID', 'PARENT'); Print_r ($c);

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.0090.00616.50
8.3.50.0120.00917.32
8.3.40.0120.00318.60
8.3.30.0110.00318.64
8.3.20.0050.00318.73
8.3.10.0090.00020.39
8.3.00.0080.00019.38
8.2.180.0110.00716.32
8.2.170.0140.00722.96
8.2.160.0070.01120.95
8.2.150.0030.00524.18
8.2.140.0000.00724.66
8.2.130.0040.00426.16
8.2.120.0050.00319.36
8.2.110.0040.00820.99
8.2.100.0080.00417.91
8.2.90.0040.00421.00
8.2.80.0000.00818.05
8.2.70.0090.00017.63
8.2.60.0070.00218.03
8.2.50.0060.00318.07
8.2.40.0040.00418.16
8.2.30.0070.00018.06
8.2.20.0080.00017.65
8.2.10.0070.00017.78
8.2.00.0080.00017.75
8.1.280.0130.00325.92
8.1.270.0070.00023.99
8.1.260.0040.00426.35
8.1.250.0090.00028.09
8.1.240.0000.01020.88
8.1.230.0070.00420.89
8.1.220.0000.00817.79
8.1.210.0040.00418.85
8.1.200.0030.00717.35
8.1.190.0040.00417.65
8.1.180.0040.00418.10
8.1.170.0080.00018.90
8.1.160.0040.00418.80
8.1.150.0000.00718.66
8.1.140.0030.00517.48
8.1.130.0070.00017.83
8.1.120.0000.00717.42
8.1.110.0030.00617.41
8.1.100.0000.00717.38
8.1.90.0070.00017.46
8.1.80.0070.00017.50
8.1.70.0000.01017.50
8.1.60.0040.00417.67
8.1.50.0000.00917.46
8.1.40.0060.00317.56
8.1.30.0030.00617.65
8.1.20.0040.00417.63
8.1.10.0000.00817.60
8.1.00.0070.00017.49
8.0.300.0070.00020.04
8.0.290.0000.00716.63
8.0.280.0000.00718.38
8.0.270.0030.00517.20
8.0.260.0050.00316.78
8.0.250.0070.00016.89
8.0.240.0080.00016.87
8.0.230.0030.00316.90
8.0.220.0040.00416.95
8.0.210.0000.00716.89
8.0.200.0000.00616.85
8.0.190.0070.00016.93
8.0.180.0000.00716.97
8.0.170.0040.00416.89
8.0.160.0030.00316.76
8.0.150.0000.00816.75
8.0.140.0050.00316.80
8.0.130.0000.00613.32
8.0.120.0040.00416.93
8.0.110.0070.00016.94
8.0.100.0040.00416.78
8.0.90.0050.00217.02
8.0.80.0040.01416.84
8.0.70.0070.00016.82
8.0.60.0040.00416.68
8.0.50.0030.00516.78
8.0.30.0080.01217.01
8.0.20.0100.00917.16
8.0.10.0060.00317.04
8.0.00.0120.00716.67
7.4.330.0030.00312.95
7.4.320.0070.00016.59
7.4.300.0000.00616.53
7.4.290.0030.00316.61
7.4.280.0050.00316.54
7.4.270.0040.00416.58
7.4.260.0030.00313.23
7.4.250.0040.00416.58
7.4.240.0030.00316.63
7.4.230.0080.00016.47
7.4.220.0240.02016.62
7.4.210.0070.00916.58
7.4.200.0000.00916.44
7.4.190.0030.00316.68
7.4.160.0100.00716.74
7.4.150.0120.00616.55
7.4.140.0130.01016.47
7.4.130.0110.00616.60
7.4.120.0120.00416.52
7.4.110.0140.00316.45
7.4.100.0030.01616.45
7.4.90.0080.00816.47
7.4.80.0140.00719.39
7.4.70.0030.01716.65
7.4.60.0100.01316.40
7.4.50.0000.00716.57
7.4.40.0040.01116.70
7.4.30.0090.00916.50
7.4.00.0080.01114.91
7.3.330.0000.00613.46
7.3.320.0030.00313.23
7.3.310.0040.00416.45
7.3.300.0000.00716.32
7.3.290.0160.00316.52
7.3.280.0070.01116.36
7.3.270.0130.00316.61
7.3.260.0090.01016.64
7.3.250.0080.01216.64
7.3.240.0070.01016.44
7.3.230.0000.02116.34
7.3.210.0070.00916.66
7.3.200.0070.01016.41
7.3.190.0050.01516.36
7.3.180.0060.01116.43
7.3.170.0140.00716.56
7.3.160.0090.00616.56
7.3.120.0080.00814.82
7.3.110.0110.00714.73
7.3.100.0040.01515.11
7.3.90.0070.01015.00
7.3.80.0070.01014.84
7.3.70.0040.01214.98
7.3.60.0070.00414.80
7.3.50.0000.01214.99
7.3.40.0030.01014.63
7.3.30.0070.00314.97
7.3.20.0090.00616.81
7.3.10.0040.01116.61
7.3.00.0030.01016.62
7.2.330.0100.01016.55
7.2.320.0170.00016.51
7.2.310.0090.01916.44
7.2.300.0100.00716.85
7.2.290.0070.01316.82
7.2.250.0090.00615.25
7.2.240.0060.01214.81
7.2.230.0070.01014.99
7.2.220.0030.01014.95
7.2.210.0030.01015.05
7.2.200.0040.01115.18
7.2.190.0030.00615.13
7.2.180.0040.01114.89
7.2.170.0030.00615.09
7.2.160.0040.01115.24
7.2.150.0000.01916.79
7.2.140.0090.00917.00
7.2.130.0120.00317.04
7.2.120.0090.00917.08
7.2.110.0040.00816.96
7.2.100.0090.00616.74
7.2.90.0100.00317.10
7.2.80.0090.00617.03
7.2.70.0000.01817.10
7.2.60.0110.00316.63
7.2.50.0130.00017.02
7.2.40.0070.00717.10
7.2.30.0100.01016.96
7.2.20.0090.00617.07
7.2.10.0070.00717.03
7.2.00.0080.00818.20
7.1.330.0080.00615.97
7.1.320.0070.01015.83
7.1.310.0030.00615.86
7.1.300.0000.00915.79
7.1.290.0070.00715.89
7.1.280.0000.00815.57
7.1.270.0090.00015.82
7.1.260.0030.01715.77
7.1.250.0050.00815.78
7.1.240.0100.00315.70
7.1.230.0000.00815.57
7.1.220.0030.01315.78
7.1.210.0030.00615.71
7.1.200.0100.00615.69
7.1.190.0100.00315.97
7.1.180.0060.00615.95
7.1.170.0030.00615.75
7.1.160.0030.01015.95
7.1.150.0040.01415.68
7.1.140.0030.01015.92
7.1.130.0070.00715.96
7.1.120.0000.01515.73
7.1.110.0030.01015.78
7.1.100.0480.00814.04
7.1.90.0060.00915.87
7.1.80.0030.01015.78
7.1.70.0060.00416.41
7.1.60.0130.00717.69
7.1.50.0030.01016.33
7.1.40.0000.01415.81
7.1.30.0090.00315.60
7.1.20.0040.00815.69
7.1.10.0060.00915.82
7.1.00.0020.04619.06
7.0.330.0040.01115.50
7.0.320.0130.00315.37
7.0.310.0000.01115.63
7.0.300.0060.00915.42
7.0.290.0040.00715.40
7.0.280.0070.01015.50
7.0.270.0060.00615.31
7.0.260.0110.00715.44
7.0.250.0110.00715.44
7.0.240.0090.00915.43
7.0.230.0090.00615.62
7.0.220.0110.00715.53
7.0.210.0080.00815.43
7.0.200.0090.01015.00
7.0.190.0000.01415.53
7.0.180.0070.01015.26
7.0.170.0070.00715.45
7.0.160.0070.01015.57
7.0.150.0060.01315.54
7.0.140.0080.03818.70
7.0.130.0130.00315.39
7.0.120.0100.03818.88
7.0.110.0040.01115.38
7.0.100.0080.00815.47
7.0.90.0070.00715.43
7.0.80.0060.00915.16
7.0.70.0030.01015.21
7.0.60.0080.04318.46
7.0.50.0070.04916.62
7.0.40.0130.04016.74
7.0.30.0170.02816.89
7.0.20.0200.03016.84
7.0.10.0100.03816.84
7.0.00.0100.04516.82
5.6.400.0140.01014.50
5.6.390.0070.01114.39
5.6.380.0030.01314.60
5.6.370.0150.00414.78
5.6.360.0080.00614.47
5.6.350.0090.00914.64
5.6.340.0070.01014.64
5.6.330.0100.00714.45
5.6.320.0100.00314.46
5.6.310.0110.01114.39
5.6.300.0100.00314.35
5.6.290.0060.00914.32
5.6.280.0130.03517.63
5.6.270.0060.00614.57
5.6.260.0040.00714.29
5.6.250.0060.01314.73
5.6.240.0060.01014.37
5.6.230.0090.00914.48
5.6.220.0120.00614.13
5.6.210.0080.04017.50
5.6.200.0130.03216.26
5.6.190.0050.02717.42
5.6.180.0200.04017.39
5.6.170.0230.04317.50
5.6.160.0120.03017.45
5.6.150.0020.02716.36
5.6.140.0070.04616.21
5.6.130.0050.03316.26
5.6.120.0030.02717.73
5.6.110.0090.04417.65
5.6.100.0090.02417.67
5.6.90.0180.03717.55
5.6.80.0080.03817.37
5.6.70.0080.00614.32
5.6.60.0040.00814.70
5.6.50.0060.01214.35
5.6.40.0070.01014.37
5.6.30.0060.00914.63
5.6.20.0070.01014.30
5.6.10.0060.00914.33
5.6.00.0030.01414.38
5.5.380.0120.00314.33
5.5.370.0090.00814.36
5.5.360.0100.00714.41
5.5.350.0110.02317.24
5.5.340.0060.03816.02
5.5.330.0060.03317.27
5.5.320.0100.02517.35
5.5.310.0220.03517.42
5.5.300.0090.02216.14
5.5.290.0160.02216.11
5.5.280.0040.04217.83
5.5.270.0100.03517.60
5.5.260.0070.05017.65
5.5.250.0150.04317.60
5.5.240.0180.03017.35
5.5.230.0110.01114.52
5.5.220.0090.00614.42
5.5.210.0120.00614.14
5.5.200.0070.00714.38
5.5.190.0060.01514.45
5.5.180.0040.01214.28
5.5.170.0040.01214.56
5.5.160.0070.01414.30
5.5.150.0110.00314.71
5.5.140.0000.01814.47
5.5.130.0070.01014.42
5.5.120.0060.01014.41
5.5.110.0120.00614.48
5.5.100.0120.00414.51
5.5.90.0060.00614.55
5.5.80.0110.00314.24
5.5.70.0070.00413.92
5.5.60.0040.01413.98
5.5.50.0110.00714.23
5.5.40.0040.01414.21
5.5.30.0100.00314.34
5.5.20.0000.02214.33
5.5.10.0090.00914.27
5.5.00.0030.01414.57
5.4.450.0100.04015.84
5.4.440.0100.03815.84
5.4.430.0050.02615.83
5.4.420.0050.02515.70
5.4.410.0100.02815.80
5.4.400.0090.02615.72
5.4.390.0100.04415.68
5.4.380.0080.02615.72
5.4.370.0100.03315.72
5.4.360.0080.02215.72
5.4.350.0110.03515.59
5.4.340.0070.02715.72
5.4.330.0090.00312.20
5.4.320.0080.04015.72
5.4.310.0080.02315.66
5.4.300.0080.03815.56
5.4.290.0050.02515.61
5.4.280.0030.02515.60
5.4.270.0080.04315.66
5.4.260.0060.02615.60
5.4.250.0030.02615.67
5.4.240.0050.02915.58
5.4.230.0100.04215.72
5.4.220.0100.04015.70
5.4.210.0090.03715.72
5.4.200.0090.02315.68
5.4.190.0060.03115.70
5.4.180.0100.02315.71
5.4.170.0100.03515.63
5.4.160.0050.03815.66
5.4.150.0040.04415.71
5.4.140.0030.03214.26
5.4.130.0030.02914.33
5.4.120.0070.03714.29
5.4.110.0130.03814.34
5.4.100.0070.02214.37
5.4.90.0070.04014.34
5.4.80.0150.03014.31
5.4.70.0100.01814.27
5.4.60.0070.03914.24
5.4.50.0060.03514.35
5.4.40.0040.02614.35
5.4.30.0050.02114.34
5.4.20.0050.02414.29
5.4.10.0080.02314.30
5.4.00.0090.03914.03
5.3.290.0100.02713.51
5.3.280.0100.02813.42
5.3.270.0080.04313.44
5.3.260.0100.03013.45
5.3.250.0070.02713.45
5.3.240.0100.03713.42
5.3.230.0090.03513.44
5.3.220.0070.04213.42
5.3.210.0100.03513.41
5.3.200.0090.04113.34
5.3.190.0090.03213.39
5.3.180.0040.03213.38
5.3.170.0020.02913.47
5.3.160.0050.02713.39
5.3.150.0090.03413.42
5.3.140.0090.02013.37
5.3.130.0100.02713.46
5.3.120.0050.02713.41
5.3.110.0110.04013.39
5.3.100.0090.03013.16
5.3.90.0060.02113.11
5.3.80.0070.04313.13
5.3.70.0070.03413.14
5.3.60.0060.03513.13
5.3.50.0090.03213.11
5.3.40.0050.03113.11
5.3.30.0110.02013.08
5.3.20.0110.02112.98
5.3.10.0030.02512.93
5.3.00.0030.04312.91
5.2.170.0030.05011.22
5.2.160.0070.03711.23
5.2.150.0100.05311.08
5.2.140.0130.04311.16
5.2.130.0130.03011.13
5.2.120.0100.05011.13
5.2.110.0100.03311.11
5.2.100.0000.03311.09
5.2.90.0030.03011.13
5.2.80.0030.03011.03
5.2.70.0070.06311.18
5.2.60.0070.04011.07
5.2.50.0130.05711.03
5.2.40.0030.03311.00
5.2.30.0030.03310.99
5.2.20.0000.03710.98
5.2.10.0030.05310.84
5.2.00.0100.02710.90
5.1.60.0070.04010.08
5.1.50.0030.03710.01
5.1.40.0030.0239.97
5.1.30.0000.04010.35
5.1.20.0170.05010.40
5.1.10.0030.06010.00
5.1.00.0070.04310.14
5.0.50.0000.0308.64
5.0.40.0030.0238.45
5.0.30.0070.0508.51
5.0.20.0030.0208.56
5.0.10.0070.0308.56
5.0.00.0000.0738.56
4.4.90.0100.0138.04
4.4.80.0030.0308.04
4.4.70.0000.0208.08
4.4.60.0000.0208.09
4.4.50.0070.0338.13
4.4.40.0030.0408.21
4.4.30.0030.0208.26
4.4.20.0030.0278.32
4.4.10.0070.0178.39
4.4.00.0000.0278.41
4.3.110.0030.0178.50
4.3.100.0030.0238.53
4.3.90.0070.0138.56
4.3.80.0000.0308.56
4.3.70.0070.0308.56
4.3.60.0000.0208.56
4.3.50.0000.0178.56
4.3.40.0030.0238.56
4.3.30.0000.0178.56
4.3.20.0070.0308.56
4.3.10.0000.0178.56
4.3.00.0000.0278.56

preferences:
45.4 ms | 401 KiB | 5 Q