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); // if null presume section? return is_null($parent) ? '/'.$article->parentPage.'/'.$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.0060.01216.49
8.3.50.0110.00521.15
8.3.40.0120.00618.71
8.3.30.0160.00618.71
8.3.20.0050.00318.64
8.3.10.0080.00021.71
8.3.00.0060.00321.85
8.2.180.0160.00616.75
8.2.170.0070.01022.96
8.2.160.0070.00722.18
8.2.150.0030.00624.18
8.2.140.0000.00724.66
8.2.130.0040.00419.77
8.2.120.0040.00426.35
8.2.110.0080.00320.38
8.2.100.0120.00017.84
8.2.90.0000.00818.05
8.2.80.0050.00317.97
8.2.70.0050.00318.05
8.2.60.0040.00418.05
8.2.50.0030.00619.48
8.2.40.0080.00020.59
8.2.30.0000.00819.26
8.2.20.0040.00418.09
8.2.10.0000.00818.25
8.2.00.0040.00417.70
8.1.280.0120.00325.92
8.1.270.0040.00422.21
8.1.260.0070.00028.09
8.1.250.0070.00028.09
8.1.240.0030.00623.92
8.1.230.0040.00719.04
8.1.220.0040.00417.79
8.1.210.0030.00518.77
8.1.200.0090.00317.36
8.1.190.0000.00817.10
8.1.180.0050.00318.10
8.1.170.0030.00518.48
8.1.160.0000.00722.13
8.1.150.0070.00020.59
8.1.140.0050.00319.63
8.1.130.0000.00717.75
8.1.120.0000.00817.37
8.1.110.0000.00717.42
8.1.100.0060.00317.42
8.1.90.0070.00017.54
8.1.80.0040.00417.52
8.1.70.0040.00417.53
8.1.60.0000.00717.59
8.1.50.0080.00017.44
8.1.40.0070.00317.60
8.1.30.0030.00617.53
8.1.20.0040.00417.49
8.1.10.0000.00917.63
8.1.00.0070.00017.41
8.0.300.0000.00719.53
8.0.290.0040.00416.88
8.0.280.0000.00718.59
8.0.270.0030.00317.22
8.0.260.0000.00617.24
8.0.250.0000.00716.94
8.0.240.0030.00316.99
8.0.230.0000.00817.04
8.0.220.0070.00016.94
8.0.210.0060.00016.82
8.0.200.0000.00716.88
8.0.190.0040.00417.04
8.0.180.0040.00416.85
8.0.170.0090.00016.99
8.0.160.0040.00416.83
8.0.150.0040.00416.86
8.0.140.0040.00416.94
8.0.130.0000.00613.46
8.0.120.0070.00316.89
8.0.110.0030.00516.78
8.0.100.0040.00416.83
8.0.90.0040.00416.97
8.0.80.0070.01416.99
8.0.70.0070.00016.95
8.0.60.0070.00016.81
8.0.50.0040.00416.87
8.0.30.0100.00817.22
8.0.20.0100.00817.40
8.0.10.0040.00416.88
8.0.00.0120.00616.83
7.4.330.0000.00515.55
7.4.320.0030.00316.68
7.4.300.0030.00316.69
7.4.290.0000.00716.59
7.4.280.0100.00016.64
7.4.270.0030.00316.65
7.4.260.0000.00716.45
7.4.250.0000.00716.59
7.4.240.0040.00416.54
7.4.230.0070.00016.36
7.4.220.0180.00916.63
7.4.210.0000.02016.57
7.4.200.0000.00716.43
7.4.160.0060.01116.45
7.4.150.0070.01017.40
7.4.140.0100.00817.86
7.4.130.0110.00816.53
7.4.120.0120.00716.54
7.4.110.0160.00416.48
7.4.100.0140.00316.46
7.4.90.0060.01216.58
7.4.80.0120.00619.39
7.4.70.0120.00416.63
7.4.60.0130.01016.48
7.4.50.0060.00816.69
7.4.40.0060.00916.50
7.4.30.0030.01316.46
7.4.00.0070.01014.88
7.3.330.0030.00313.17
7.3.320.0000.00513.18
7.3.310.0050.00216.45
7.3.300.0070.00016.43
7.3.290.0040.01316.39
7.3.280.0100.00816.39
7.3.270.0170.00017.40
7.3.260.0110.00616.47
7.3.250.0110.00816.52
7.3.240.0080.01216.47
7.3.230.0110.01116.39
7.3.210.0140.00716.36
7.3.200.0120.00316.43
7.3.190.0030.01316.57
7.3.180.0030.01416.57
7.3.170.0090.00916.44
7.3.160.0070.01016.39
7.3.10.0150.00216.48
7.3.00.0140.00316.46
7.2.330.0150.00316.80
7.2.320.0040.01516.74
7.2.310.0100.00616.52
7.2.300.0100.00716.79
7.2.290.0060.01016.76
7.2.130.0070.00616.73
7.2.120.0070.00716.69
7.2.110.0120.00716.71
7.2.100.0040.00916.66
7.2.90.0060.00716.96
7.2.80.0020.00716.78
7.2.70.0080.00716.86
7.2.60.0060.00617.03
7.2.50.0090.00416.82
7.2.40.0110.00516.97
7.2.30.0060.00416.95
7.2.20.0080.00716.72
7.2.10.0060.01016.75
7.2.00.0050.00817.54
7.1.250.0040.00715.61
7.1.200.0080.00315.58
7.1.70.0120.00617.07
7.1.60.0030.00916.89
7.1.00.0070.07322.35
7.0.200.0230.00014.89
7.0.120.0030.06322.18
7.0.110.0170.05322.03
7.0.100.0100.05722.00
7.0.90.0170.07022.20
7.0.80.0100.08022.21
7.0.70.0100.05722.05
7.0.60.0100.05722.12
7.0.50.0100.05722.09
7.0.40.0170.04722.16
7.0.30.0200.07322.04
7.0.20.0130.06022.06
7.0.10.0100.06022.14
7.0.00.0070.06022.11
5.6.270.0070.05720.89
5.6.260.0130.07721.06
5.6.250.0300.04720.85
5.6.240.0200.05021.12
5.6.230.0030.06720.88
5.6.220.0070.06021.06
5.6.210.0130.06320.89
5.6.200.0100.06021.01
5.6.190.0070.06021.04
5.6.180.0100.06020.99
5.6.170.0130.05721.03
5.6.160.0170.05720.91
5.6.150.0300.07021.07
5.6.140.0270.06721.10
5.6.130.0130.07721.03
5.6.120.0200.07021.05
5.6.110.0130.06020.99
5.6.100.0200.07020.99
5.6.90.0130.05020.93
5.6.80.0030.06020.41
5.6.70.0030.05720.19
5.6.60.0270.04320.45
5.6.50.0230.04720.48
5.6.40.0070.06320.32
5.6.30.0030.06720.20
5.6.20.0100.05720.20
5.6.10.0030.06720.39
5.6.00.0070.07320.41

preferences:
62.25 ms | 401 KiB | 5 Q