3v4l.org

run code in 300+ PHP versions simultaneously
<?php function item_by_value($array,$key,$value) { // returns FIRST matching element only, presumes ID if ((!is_array($array)) || empty($key) || empty($value)) return false; for ($i=0; $i < count($array); $i++) { $item = (array) $array[$i]; if ($item[$key] == $value) { return $array[$i]; break; } } return null; } function article_link($article,$articles) { if (is_null($article) || !is_object($article)) {return '';} if ($article->parentPage == 'self') { return '/'.$article->id; } else { $parent = item_by_value($articles,'id',$article->parentPage); return is_null($parent) ? '/'.$article->id : article_link($parent->id,$articles).'/'.$article->id; } } $articles = json_decode('{"articles":[{"id":"about","title":"Significant Object","bodyHtml":"about-main.html","parentPage":"self","banner":"stock"},{"id":"workshops","title":"Workshops","bodyHtml":"workshops.html","parentPage":"self","banner":null},{"id":"making","title":"Making","bodyHtml":"making.html","parentPage":"self"},{"id":"the-lion-the-witch-and","title":"The Lion, The Witch and The Wardrobe","bodyHtml":"the-lion-the-witch.html","parentPage":"past"},{"id":"circus-1903","title":"Circus 1903","bodyHtml":"circus-1903.html","parentPage":"current","banner":"stock"},{"id":"dissonance","title":"Dissonance","bodyHtml":"dissonance.html","parentPage":"current"},{"id":"handspring-uk","title":"Handspring UK","bodyHtml":"handspring-uk.html","parentPage":"past","banner":"stock"},{"id":"james-ii","title":"James II","bodyHtml":"james-ii.html","parentPage":"past"},{"id":"die-bruder-lowenherz","title":"Die Brüder Löwenherz (The Brothers Lionheart)","bodyHtml":"lowenherz.html","parentPage":"past"},{"id":"newman","title":"Newman","bodyHtml":"newman.html","parentPage":"past"},{"id":"stiller","title":"Stiller","bodyHtml":"stiller.html","parentPage":"past"},{"id":"the-loris","title":"The Loris","bodyHtml":"the-loris.html","parentPage":"past"},{"id":"reviews-of-stiller","title":"Press Reviews of Stiller","bodyHtml":"reviews-of-stiller.html","parentPage":"stiller","banner":"none"},{"id":"jubilee-salute","title":"Jubilee Salute","bodyHtml":"jubilee-salute-handspring-UK.html","parentPage":"past"},{"id":"crow","title":"Crow","bodyHtml":"crow.html","parentPage":"past"}]}'); $test = $articles->articles[10]; $array = $articles->articles; echo article_link($test,$array);

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.0140.00416.50
8.3.50.0170.00221.08
8.3.40.0040.01418.80
8.3.30.0040.01818.79
8.3.20.0040.01118.75
8.3.10.0000.00721.80
8.3.00.0040.00421.95
8.2.180.0000.01816.50
8.2.170.0090.00622.96
8.2.160.0070.00722.22
8.2.150.0090.00024.18
8.2.140.0000.00824.66
8.2.130.0000.00719.77
8.2.120.0080.00026.35
8.2.110.0060.00320.45
8.2.100.0080.00317.91
8.2.90.0040.00417.93
8.2.80.0040.00418.03
8.2.70.0030.00617.90
8.2.60.0000.00818.05
8.2.50.0000.00818.10
8.2.40.0000.00820.46
8.2.30.0030.00519.36
8.2.20.0000.00718.15
8.2.10.0040.00418.04
8.2.00.0040.00417.84
8.1.280.0100.00625.92
8.1.270.0030.00622.00
8.1.260.0040.00428.09
8.1.250.0040.00428.09
8.1.240.0050.00523.79
8.1.230.0000.01119.10
8.1.220.0030.00517.74
8.1.210.0000.00818.77
8.1.200.0060.00317.35
8.1.190.0050.00317.25
8.1.180.0000.00818.10
8.1.170.0030.00518.66
8.1.160.0000.00722.17
8.1.150.0000.00720.63
8.1.140.0050.00319.53
8.1.130.0050.00317.68
8.1.120.0020.00517.50
8.1.110.0030.00517.40
8.1.100.0000.00817.39
8.1.90.0000.00717.40
8.1.80.0000.00717.37
8.1.70.0000.00717.53
8.1.60.0040.00417.61
8.1.50.0060.00317.56
8.1.40.0060.00617.51
8.1.30.0030.00617.64
8.1.20.0000.00717.59
8.1.10.0040.00417.59
8.1.00.0050.00317.55
8.0.300.0000.00719.60
8.0.290.0020.00516.61
8.0.280.0000.00718.40
8.0.270.0000.00717.22
8.0.260.0000.00617.30
8.0.250.0000.00717.00
8.0.240.0030.00517.06
8.0.230.0000.00717.02
8.0.220.0000.00716.97
8.0.210.0030.00316.98
8.0.200.0030.00316.95
8.0.190.0030.00517.06
8.0.180.0030.00516.96
8.0.170.0070.00016.95
8.0.160.0000.00717.01
8.0.150.0040.00416.84
8.0.140.0040.00416.94
8.0.130.0060.00013.34
8.0.120.0030.00516.86
8.0.110.0000.00716.80
8.0.100.0070.00016.86
8.0.90.0000.00716.80
8.0.80.0090.00616.92
8.0.70.0050.00217.00
8.0.60.0040.00416.84
8.0.50.0040.00416.91
8.0.30.0130.00717.10
8.0.20.0070.01317.40
8.0.10.0000.00816.88
8.0.00.0120.00716.79
7.4.330.0000.00515.55
7.4.320.0040.00416.59
7.4.300.0070.00016.55
7.4.290.0000.00716.39
7.4.280.0000.01016.39
7.4.270.0030.00316.57
7.4.260.0040.00416.57
7.4.250.0070.00016.59
7.4.240.0080.00016.64
7.4.230.0000.00716.38
7.4.220.0090.01016.66
7.4.210.0100.00616.74
7.4.200.0000.00716.74
7.4.160.0120.00316.48
7.4.150.0070.01017.40
7.4.140.0090.01217.86
7.4.130.0100.00716.60
7.4.120.0080.00916.50
7.4.110.0090.00916.33
7.4.100.0070.01016.40
7.4.90.0160.00716.46
7.4.80.0110.00619.39
7.4.70.0080.00816.47
7.4.60.0030.01616.30
7.4.50.0060.00616.64
7.4.40.0110.00616.62
7.4.30.0120.00816.56
7.4.00.0040.01415.18
7.3.330.0050.00013.38
7.3.320.0050.00013.22
7.3.310.0030.00316.30
7.3.300.0000.00716.45
7.3.290.0100.00516.41
7.3.280.0100.00616.38
7.3.270.0070.01017.40
7.3.260.0100.01016.50
7.3.250.0100.00716.59
7.3.240.0140.00816.38
7.3.230.0120.00616.44
7.3.210.0160.00416.52
7.3.200.0070.01016.61
7.3.190.0100.00716.48
7.3.180.0070.01416.52
7.3.170.0080.00816.59
7.3.160.0130.01016.57
7.2.330.0030.01616.55
7.2.320.0090.00916.83
7.2.310.0060.01016.82
7.2.300.0110.00616.65
7.2.290.0030.01316.78
7.2.120.0100.00316.83
7.2.110.0100.00716.37
7.2.100.0000.01416.66
7.2.90.0030.00716.73
7.2.80.0040.01116.48
7.2.70.0070.00717.01
7.2.60.0070.00417.18
7.2.50.0040.00817.08
7.2.40.0040.01116.97
7.2.30.0060.00616.85
7.2.20.0090.00617.03
7.2.10.0060.00616.73
7.2.00.0080.00818.23
7.1.240.0110.00415.96
7.1.230.0080.00315.79
7.1.220.0060.00915.94
7.1.210.0090.00915.60
7.1.200.0040.00715.87
7.1.190.0150.00715.89
7.1.180.0040.00815.87
7.1.170.0030.00916.01
7.1.160.0090.00315.87
7.1.150.0960.00315.88
7.1.140.0130.00015.59
7.1.130.0160.00415.55
7.1.120.0000.01515.71
7.1.110.0090.00315.86
7.1.100.0070.00715.96
7.1.90.0090.00615.76
7.1.80.0110.00415.59
7.1.70.0070.00416.50
7.1.60.0050.00616.41
7.1.50.0110.00315.76
7.1.40.0070.00715.90
7.1.30.0120.00615.79
7.1.20.0060.01115.79
7.1.10.0090.00915.70
7.1.00.0090.03919.30
7.0.320.0030.00515.39
7.0.310.0060.00915.46
7.0.300.0000.01015.39
7.0.290.0000.00715.25
7.0.280.0070.01115.48
7.0.270.0070.00615.40
7.0.260.0040.01115.42
7.0.250.0040.00915.61
7.0.240.0110.00415.23
7.0.230.0060.00915.52
7.0.220.0100.00315.38
7.0.210.0060.00615.14
7.0.200.0110.00615.27
7.0.190.0040.00815.30
7.0.180.0140.00015.50
7.0.170.0150.00415.51
7.0.160.0130.00015.34
7.0.150.0040.01215.16
7.0.140.0060.01215.54
7.0.130.0030.01015.40
7.0.120.0180.02718.72
7.0.110.0080.03318.55
7.0.100.0130.03318.72
7.0.90.0180.02518.75
7.0.80.0130.02818.78
7.0.70.0140.02718.64
7.0.60.0120.03518.62
7.0.50.0140.03318.85
7.0.40.0170.03317.62
7.0.30.0090.04117.68
7.0.20.0160.03017.79
7.0.10.0150.02817.72
7.0.00.0110.03317.73
5.6.380.0110.00314.39
5.6.370.0040.01114.72
5.6.360.0030.00714.30
5.6.350.0100.00314.38
5.6.340.0040.00814.18
5.6.330.0100.00214.68
5.6.320.0080.00513.93
5.6.310.0070.00714.50
5.6.300.0090.00614.39
5.6.290.0110.00614.70
5.6.280.0090.00814.17
5.6.270.0130.03317.74
5.6.260.0040.03717.83
5.6.250.0160.03017.59
5.6.240.0080.03717.64
5.6.230.0120.03417.63
5.6.220.0150.03017.79
5.6.210.0160.03017.59
5.6.200.0150.04217.63
5.6.190.0220.03117.77
5.6.180.0150.02917.64
5.6.170.0070.03517.72
5.6.160.0130.03017.72
5.6.150.0080.03917.66
5.6.140.0150.03217.63
5.6.130.0200.03017.66
5.6.120.0080.04617.78
5.6.110.0200.03717.65
5.6.100.0110.03417.84
5.6.90.0120.03417.77
5.6.80.0080.03517.18
5.6.70.0130.03817.28
5.6.60.0080.04517.33
5.6.50.0140.02517.29
5.6.40.0120.02917.35
5.6.30.0050.03717.29
5.6.20.0100.03517.38
5.6.10.0090.03417.34
5.6.00.0080.03417.46

preferences:
71.31 ms | 401 KiB | 5 Q