3v4l.org

run code in 300+ PHP versions simultaneously
<?php function createTree($array){ $tree = []; foreach($array as $v){ $v = str_split($v); $tmp = &$tree; while($c = array_shift($v)) $tmp = &$tmp[strtolower($c)]; unset($tmp); } return $tree; } function findNode($value, $treeTmp){ foreach($value as $k){ if(!array_key_exists(strtolower($k), $treeTmp)) return FALSE; else $treeTmp = $treeTmp[$k]; } return TRUE; } /* ------------ */ $data = ["round", "roundish", "word"]; $searchValue = "round"; //Normal lookU **very slow** $result = in_array($searchValue, $data); var_dump($result); //Faster lookUp $tree = createTree($data); print_r($tree); $result = findNode(str_split($searchValue), $tree); var_dump($result); //PROBLEM -> It also finds values which don't exist in '$data' $searchValue = "ro"; //I DO NOT EXIST IN $data $result = findNode(str_split($searchValue), $tree); var_dump($result); ?>

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.140.0110.01217.50
8.4.130.0140.00717.45
8.4.120.0100.00920.35
8.4.110.0070.00222.29
8.4.100.0120.00917.97
8.4.90.0120.00918.63
8.4.80.0090.00519.40
8.4.70.0050.00417.88
8.4.60.0110.01020.35
8.4.50.0090.01120.36
8.4.40.0100.01019.34
8.4.30.0100.01017.49
8.4.20.0090.01217.88
8.4.10.0090.00617.42
8.3.260.0070.00616.57
8.3.250.0110.00618.69
8.3.240.0090.01016.64
8.3.230.0100.01016.64
8.3.220.0040.00317.14
8.3.210.0110.00518.50
8.3.200.0040.00516.61
8.3.190.0100.00917.22
8.3.180.0110.00817.10
8.3.170.0060.01317.31
8.3.160.0190.00018.28
8.3.150.0100.01016.80
8.3.140.0030.01616.98
8.3.130.0070.00318.45
8.3.120.0050.00519.13
8.3.110.0040.00720.94
8.3.100.0000.00824.06
8.3.90.0130.00326.77
8.3.80.0060.00318.25
8.3.70.0090.00618.26
8.3.60.0150.00318.30
8.3.50.0100.00522.85
8.3.40.0080.00618.84
8.3.30.0110.00418.79
8.3.20.0080.00020.34
8.3.10.0050.00221.82
8.3.00.0030.00519.11
8.2.290.0100.00920.82
8.2.280.0060.00218.17
8.2.270.0100.00717.24
8.2.260.0110.00718.42
8.2.250.0090.00916.66
8.2.240.0080.00017.05
8.2.230.0130.00722.58
8.2.220.0030.00637.54
8.2.210.0120.00326.77
8.2.200.0030.00916.88
8.2.190.0120.00616.58
8.2.180.0040.01118.42
8.2.170.0070.01422.96
8.2.160.0030.01019.18
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0080.00022.14
8.2.120.0040.00426.35
8.2.110.0040.00419.39
8.2.100.0090.00317.93
8.2.90.0000.00819.22
8.2.80.0080.00017.97
8.2.70.0060.00317.50
8.2.60.0000.00917.93
8.2.50.0000.00818.10
8.2.40.0040.00420.59
8.2.30.0000.00819.22
8.2.20.0060.00317.83
8.2.10.0000.00718.16
8.2.00.0040.00418.25
8.1.330.0130.00621.97
8.1.320.0140.00616.42
8.1.310.0060.00318.60
8.1.300.0040.01520.03
8.1.290.0050.00530.84
8.1.280.0070.01025.92
8.1.270.0080.00023.96
8.1.260.0000.00828.09
8.1.250.0040.00428.09
8.1.240.0100.00021.25
8.1.230.0110.00017.83
8.1.220.0060.00317.77
8.1.210.0000.00818.77
8.1.200.0000.01017.38
8.1.190.0040.00417.22
8.1.180.0060.00318.10
8.1.170.0080.00018.55
8.1.160.0000.00719.00
8.1.150.0030.00418.96
8.1.140.0000.00719.66
8.1.130.0070.00017.73
8.1.120.0030.00517.42
8.1.110.0080.00017.47
8.1.100.0000.00717.45
8.1.90.0060.00317.52
8.1.80.0030.00417.50
8.1.70.0030.00317.52
8.1.60.0040.00417.50
8.1.50.0000.00817.50
8.1.40.0000.00817.51
8.1.30.0030.00617.57
8.1.20.0050.00317.59
8.1.10.0090.00017.58
8.1.00.0000.00817.41
8.0.300.0000.00818.77
8.0.290.0020.00516.63
8.0.280.0030.00318.53
8.0.270.0000.00717.28
8.0.260.0000.00818.48
8.0.250.0040.00416.88
8.0.240.0060.00316.98
8.0.230.0040.00416.89
8.0.220.0050.00316.78
8.0.210.0040.00416.82
8.0.200.0000.00617.02
8.0.190.0040.00416.85
8.0.180.0040.00416.79
8.0.170.0000.00816.87
8.0.160.0000.00716.86
8.0.150.0030.00616.84
8.0.140.0030.00316.77
8.0.130.0030.00313.30
8.0.120.0030.00516.89
8.0.110.0000.00716.97
8.0.100.0000.00716.93
8.0.90.0000.00716.79
8.0.80.0000.01416.80
8.0.70.0040.00416.71
8.0.60.0040.00416.96
8.0.50.0080.00016.81
8.0.30.0140.00617.22
8.0.20.0090.01117.40
8.0.10.0050.00216.93
8.0.00.0130.00916.81
7.4.330.0020.00215.08
7.4.320.0060.00016.51
7.4.300.0070.00016.54
7.4.290.0000.00716.47
7.4.280.0000.00716.63
7.4.270.0000.00716.52
7.4.260.0000.00716.56
7.4.250.0030.00316.48
7.4.240.0070.00016.54
7.4.230.0000.00816.65
7.4.220.0130.00616.55
7.4.210.0110.00316.48
7.4.200.0030.00316.72
7.4.160.0120.00916.46
7.4.150.0090.00917.40
7.4.140.0110.00917.86
7.4.130.0080.00816.60
7.4.120.0090.01116.48
7.4.110.0210.00016.57
7.4.100.0070.01516.66
7.4.90.0140.00416.59
7.4.80.0000.01719.39
7.4.70.0110.00716.45
7.4.60.0030.01316.68
7.4.50.0060.00816.48
7.4.40.0150.00416.68
7.4.30.0070.01016.42
7.4.00.0080.00814.94
7.3.330.0020.00213.32
7.3.320.0030.00313.32
7.3.310.0040.00416.40
7.3.300.0030.00316.35
7.3.290.0070.01116.37
7.3.280.0090.01016.41
7.3.270.0070.01017.40
7.3.260.0200.01416.40
7.3.250.0080.01116.50
7.3.240.0090.01016.52
7.3.230.0080.00816.44
7.3.210.0090.00916.58
7.3.200.0110.00816.66
7.3.190.0040.01616.56
7.3.180.0120.00316.69
7.3.170.0120.00816.55
7.3.160.0180.01116.39
7.3.120.0130.00614.86
7.3.110.0070.01414.82
7.3.100.0100.00314.69
7.3.90.0060.00615.01
7.3.80.0060.00614.47
7.3.70.0040.00414.64
7.3.60.0080.00814.99
7.3.50.0000.00914.82
7.3.40.0000.01514.75
7.3.30.0060.00614.79
7.3.20.0060.00316.48
7.3.10.0120.00416.61
7.3.00.0050.00716.29
7.2.330.0040.01416.71
7.2.320.0060.01116.85
7.2.310.0090.00916.91
7.2.300.0040.01216.81
7.2.290.0090.00916.79
7.2.250.0100.01315.20
7.2.240.0100.01014.95
7.2.230.0090.00915.06
7.2.220.0090.00615.28
7.2.210.0090.00315.16
7.2.200.0090.00614.73
7.2.190.0000.01115.10
7.2.180.0070.01015.19
7.2.170.0040.01114.95
7.2.130.0110.00316.61
7.2.120.0110.00816.87
7.2.110.0050.01016.57
7.2.100.0060.00416.68
7.2.90.0110.01016.79
7.2.80.0090.00516.86
7.2.70.0070.00716.79
7.2.60.0070.00616.91
7.2.50.0090.00216.90
7.2.40.0080.00316.72
7.2.30.0050.00716.89
7.2.20.0060.00616.73
7.2.10.0090.00216.79
7.2.00.0050.00917.75
7.1.330.0030.01015.91
7.1.320.0060.00315.72
7.1.310.0060.00615.40
7.1.300.0110.00415.68
7.1.290.0040.01215.76
7.1.280.0060.00315.50
7.1.270.0000.01615.80
7.1.260.0070.00715.64
7.1.250.0060.01015.70
7.1.200.0040.00815.76
7.1.70.0040.00417.10
7.1.60.0030.02019.90
7.1.00.0030.07722.33
7.0.200.0230.00715.07
7.0.70.0230.05719.99
7.0.60.0270.05320.01
7.0.50.0230.06320.47
7.0.40.0300.05020.44
7.0.30.0470.05720.39
7.0.20.0370.06320.42
7.0.10.0270.08720.38
7.0.00.0230.09020.29
5.6.280.0070.06721.00
5.6.220.0170.07720.80
5.6.210.0200.05720.73
5.6.200.0300.06321.10
5.6.190.0200.06021.02
5.6.180.0170.06720.99
5.6.170.0300.07721.16
5.6.160.0170.06321.20
5.6.150.0300.08021.08
5.6.140.0300.05321.00
5.6.130.0230.06321.01
5.6.120.0130.06321.17
5.6.110.0070.07321.01
5.6.100.0270.06321.07
5.6.90.0270.07021.10
5.6.80.0200.06020.41
5.6.70.0130.06020.52
5.6.60.0230.05320.36
5.6.50.0270.06720.56
5.6.40.0300.05720.36
5.6.30.0370.06320.46
5.6.20.0400.04720.38
5.6.10.0330.06720.44
5.6.00.0230.06020.52
5.5.360.0230.06020.62
5.5.350.0330.06020.52
5.5.340.0170.06320.87
5.5.330.0200.06720.96
5.5.320.0270.05020.97
5.5.310.0300.05320.89
5.5.300.0230.06020.94
5.5.290.0330.05720.92
5.5.280.0170.05720.96
5.5.270.0300.05020.99
5.5.260.0330.06320.95
5.5.250.0130.07020.76
5.5.240.0200.05320.22
5.5.230.0300.06020.27
5.5.220.0230.05720.32
5.5.210.0270.05320.23
5.5.200.0200.06720.33
5.5.190.0270.06320.34
5.5.180.0270.07320.22
5.5.160.0230.06720.21
5.5.150.0300.06720.34
5.5.140.0330.06020.14
5.5.130.0230.05020.29
5.5.120.0270.05020.17
5.5.110.0230.05320.06
5.5.100.0270.05020.03
5.5.90.0200.05320.02
5.5.80.0170.06020.04
5.5.70.0170.06320.13
5.5.60.0230.05320.13
5.5.50.0170.05720.13
5.5.40.0230.05720.21
5.5.30.0230.06020.00
5.5.20.0200.06320.16
5.5.10.0130.06320.09
5.5.00.0230.05720.02

preferences:
35.47 ms | 403 KiB | 5 Q