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) ? 'nullo' : 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.0110.00716.36
8.3.50.0110.00316.14
8.3.40.0040.01119.02
8.3.30.0100.01318.77
8.3.20.0050.00318.57
8.3.10.0000.00721.85
8.3.00.0040.00421.90
8.2.180.0100.01016.88
8.2.170.0090.00922.96
8.2.160.0100.00322.17
8.2.150.0030.00624.18
8.2.140.0080.00024.66
8.2.130.0050.00319.96
8.2.120.0080.00026.35
8.2.110.0060.00322.26
8.2.100.0080.00417.72
8.2.90.0000.00822.15
8.2.80.0000.00917.97
8.2.70.0000.00818.05
8.2.60.0030.00517.93
8.2.50.0000.00818.10
8.2.40.0030.00620.64
8.2.30.0050.00319.38
8.2.20.0000.00718.25
8.2.10.0070.00018.00
8.2.00.0060.00317.68
8.1.280.0040.01125.92
8.1.270.0090.00022.16
8.1.260.0060.00328.09
8.1.250.0070.00028.09
8.1.240.0100.00022.19
8.1.230.0070.00420.97
8.1.220.0040.00417.91
8.1.210.0050.00319.04
8.1.200.0060.00317.35
8.1.190.0040.00417.23
8.1.180.0000.00818.10
8.1.170.0050.00318.64
8.1.160.0050.00222.19
8.1.150.0040.00420.67
8.1.140.0050.00319.62
8.1.130.0000.00717.75
8.1.120.0040.00417.58
8.1.110.0050.00217.47
8.1.100.0040.00417.40
8.1.90.0040.00417.46
8.1.80.0040.00417.48
8.1.70.0030.00317.50
8.1.60.0050.00317.50
8.1.50.0000.00817.50
8.1.40.0060.00617.63
8.1.30.0040.00417.67
8.1.20.0040.00417.65
8.1.10.0000.00817.63
8.1.00.0000.00717.57
8.0.300.0000.00820.11
8.0.290.0040.00416.88
8.0.280.0050.00318.40
8.0.270.0000.00717.19
8.0.260.0030.00317.30
8.0.250.0030.00416.98
8.0.240.0000.00716.88
8.0.230.0070.00017.05
8.0.220.0030.00316.94
8.0.210.0050.00216.99
8.0.200.0030.00317.00
8.0.190.0040.00416.88
8.0.180.0070.00016.86
8.0.170.0040.00416.87
8.0.160.0040.00416.84
8.0.150.0070.00016.77
8.0.140.0070.00016.91
8.0.130.0060.00013.41
8.0.120.0000.00916.79
8.0.110.0000.00716.79
8.0.100.0000.00817.01
8.0.90.0040.00416.78
8.0.80.0070.01016.96
8.0.70.0040.00416.83
8.0.60.0040.00416.82
8.0.50.0000.00716.94
8.0.30.0080.01017.19
8.0.20.0080.01017.40
8.0.10.0040.00417.19
8.0.00.0130.00616.68
7.4.330.0030.00315.55
7.4.320.0060.00016.55
7.4.300.0030.00316.67
7.4.290.0000.00716.64
7.4.280.0060.00416.54
7.4.270.0030.00316.56
7.4.260.0070.00016.59
7.4.250.0000.00716.56
7.4.240.0080.00016.55
7.4.230.0070.00016.76
7.4.220.0140.01016.57
7.4.210.0040.01116.60
7.4.200.0030.00316.72
7.4.160.0090.00716.52
7.4.150.0100.00717.40
7.4.140.0140.00717.86
7.4.130.0080.01016.46
7.4.120.0110.00716.56
7.4.110.0090.00916.52
7.4.100.0130.01016.64
7.4.90.0150.00316.67
7.4.80.0000.01619.39
7.4.70.0100.00616.39
7.4.60.0090.00916.60
7.4.50.0090.00616.73
7.4.40.0070.01016.48
7.4.30.0090.01016.55
7.4.00.0070.01015.08
7.3.330.0000.00513.41
7.3.320.0000.00513.24
7.3.310.0050.00216.27
7.3.300.0040.00416.50
7.3.290.0130.00516.43
7.3.280.0060.01216.41
7.3.270.0080.00817.40
7.3.260.0110.00616.46
7.3.250.0130.00516.46
7.3.240.0070.01016.57
7.3.230.0150.00416.54
7.3.210.0130.00316.60
7.3.200.0110.00516.50
7.3.190.0030.01316.56
7.3.180.0100.01016.39
7.3.170.0110.00616.63
7.3.160.0160.00716.77
7.3.10.0140.00716.26
7.3.00.0220.01116.20
7.2.330.0090.00916.86
7.2.320.0110.00716.82
7.2.310.0030.01316.58
7.2.300.0110.00716.75
7.2.290.0110.00716.82
7.2.130.0200.01317.02
7.2.120.0140.01416.55
7.2.110.0150.00716.46
7.2.100.0080.01216.12
7.2.90.0100.01016.45
7.2.80.0180.01416.93
7.2.70.0120.01216.70
7.2.60.0110.00616.69
7.2.50.0080.01116.93
7.2.40.0120.01316.48
7.2.30.0240.00716.59
7.2.20.0120.00616.52
7.2.10.0200.01016.48
7.2.00.0090.00818.03
7.1.250.0180.01415.81
7.1.200.0070.00315.54
7.1.70.0000.01117.12
7.1.60.0040.00717.26
7.1.00.0130.06722.30
7.0.200.0200.00714.98
7.0.120.0200.06722.10
7.0.110.0170.06022.01
7.0.100.0130.05322.05
7.0.90.0170.06022.19
7.0.80.0130.05722.22
7.0.70.0100.08322.14
7.0.60.0100.07722.11
7.0.50.0070.06022.08
7.0.40.0170.07021.99
7.0.30.0100.05722.07
7.0.20.0100.06322.11
7.0.10.0170.04722.14
7.0.00.0030.06722.09
5.6.270.0170.07020.87
5.6.260.0170.06321.09
5.6.250.0230.06020.99
5.6.240.0100.05720.99
5.6.230.0030.06321.07
5.6.220.0030.06021.06
5.6.210.0030.07721.03
5.6.200.0200.06721.08
5.6.190.0100.08320.76
5.6.180.0230.04721.02
5.6.170.0300.05321.05
5.6.160.0070.06020.86
5.6.150.0170.05721.05
5.6.140.0030.07320.84
5.6.130.0130.05021.09
5.6.120.0130.05721.02
5.6.110.0130.05321.00
5.6.100.0170.07021.02
5.6.90.0100.08021.04
5.6.80.0300.05320.40
5.6.70.0130.05320.22
5.6.60.0200.05720.43
5.6.50.0200.05320.44
5.6.40.0130.05020.36
5.6.30.0200.06320.21
5.6.20.0030.06020.31
5.6.10.0070.05320.40
5.6.00.0070.08020.34

preferences:
72.13 ms | 401 KiB | 5 Q