3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo '<pre>'; $id = 1035; // Searching ID $myObj = array(); $a = [ 'id'=> 291, 'children' => [ [ 'id' => 1034, 'children' => [ [ 'id' => 111, 'name' => 'ABC', 'figure' => '6 digits', 'children'=> [] ], [ 'id' => 1035, 'lft' => 'LEFT', 'children' => [ [ 'id' => 1036, 'children' => [ [ 'id' => 222, 'someKey' => 'some value', 'children'=> [] ] ] ], [ 'id' => 333, 'someKey' => 'some value', 'children'=> [] ] ], ] ], ], [ 'id' => 1024, 'title' => 'ABC', 'children' => [ ], ] ] ]; function findObject($id, $obj) { global $myObj; // This is an object. if (isset($obj["id"])) { echo "Checking {$obj["id"]}<br />"; // Check the id to what we need. if ($obj["id"] == $id) { // Yay! We found it. Return the object. echo "<strong>Yay we found {$obj["id"]}</strong><br />"; $myObj = $obj; echo "<strong>Need to find a way to break out!</strong><br />"; } else { echo "Checking children of {$obj["id"]}<br />"; // See if it has any children if (isset($obj["children"]) && count($obj["children"]) > 0) { echo "There are children for {$obj["id"]}<br />"; foreach ($obj["children"] as $child) { findObject($id, $child); } } } } } findObject($id, $a); if (isset($myObj) && !empty($myObj)) { echo "<br /><strong>Found it!</strong><br />"; print_r($myObj); } else echo "Sorry, can't find the ID!"; echo '</pre>';

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.5.10.0090.00916.62
8.5.00.0110.00919.94
8.4.160.0190.00423.88
8.4.150.0030.00014.05
8.4.140.0110.01117.80
8.4.130.0110.01017.89
8.4.120.0050.00420.71
8.4.110.0100.00818.68
8.4.100.0140.00817.86
8.4.90.0160.00417.61
8.4.80.0130.00717.70
8.4.70.0090.00817.79
8.4.60.0140.00618.80
8.4.50.0110.00820.32
8.4.40.0100.01017.96
8.4.30.0140.00719.28
8.4.20.0100.01017.97
8.4.10.0040.00417.86
8.3.280.0010.00114.05
8.3.270.0090.01016.86
8.3.260.0050.00416.75
8.3.250.0110.00919.00
8.3.240.0130.00716.84
8.3.230.0150.00516.59
8.3.220.0100.00717.17
8.3.210.0120.00616.45
8.3.200.0070.00216.53
8.3.190.0140.00617.23
8.3.180.0140.00616.63
8.3.170.0120.00617.14
8.3.160.0130.00618.41
8.3.150.0070.01118.99
8.3.140.0070.00718.78
8.3.130.0030.00518.22
8.3.120.0060.00320.95
8.3.110.0130.00620.94
8.3.100.0030.00618.43
8.3.90.0040.00426.77
8.3.80.0060.00318.43
8.3.70.0080.01116.63
8.3.60.0140.00318.56
8.3.50.0080.00518.06
8.3.40.0120.00318.89
8.3.30.0150.00018.61
8.3.20.0040.00418.82
8.3.10.0050.00320.90
8.3.00.0110.00423.65
8.2.290.0060.01220.18
8.2.280.0090.00520.27
8.2.270.0110.00717.34
8.2.260.0070.01119.02
8.2.250.0080.00316.89
8.2.240.0040.00417.40
8.2.230.0050.00522.58
8.2.220.0040.00424.06
8.2.210.0080.00326.77
8.2.200.0070.00416.25
8.2.190.0040.01216.58
8.2.180.0140.00725.92
8.2.170.0140.00422.96
8.2.160.0070.01019.26
8.2.150.0030.00524.18
8.2.140.0030.00524.66
8.2.130.0060.00321.07
8.2.120.0000.00826.35
8.2.110.0050.00522.11
8.2.100.0040.00717.91
8.2.90.0000.00920.34
8.2.80.0080.00017.97
8.2.70.0000.00817.93
8.2.60.0040.00417.93
8.2.50.0050.00318.10
8.2.40.0050.00319.47
8.2.30.0000.00819.60
8.2.20.0040.00418.04
8.2.10.0050.00318.15
8.2.00.0000.00719.45
8.1.330.0100.00916.49
8.1.320.0120.00716.03
8.1.310.0040.00418.71
8.1.300.0030.00718.07
8.1.290.0040.00730.84
8.1.280.0120.00325.92
8.1.270.0040.00421.98
8.1.260.0060.00326.35
8.1.250.0000.00828.09
8.1.240.0030.00622.41
8.1.230.0040.00820.83
8.1.220.0000.00817.77
8.1.210.0030.00618.84
8.1.200.0080.00017.22
8.1.190.0000.00817.13
8.1.180.0040.00418.10
8.1.170.0060.00318.50
8.1.160.0000.00718.91
8.1.150.0040.00418.79
8.1.140.0070.00017.72
8.1.130.0030.00319.06
8.1.120.0000.00817.49
8.1.110.0000.00817.43
8.1.100.0000.00717.38
8.1.90.0030.00617.38
8.1.80.0050.00317.54
8.1.70.0070.00017.40
8.1.60.0100.00017.64
8.1.50.0030.00617.48
8.1.40.0050.00317.51
8.1.30.0000.00717.69
8.1.20.0050.00317.66
8.1.10.0040.00417.58
8.1.00.0040.00417.61
8.0.300.0040.00420.02
8.0.290.0060.00316.63
8.0.280.0080.00018.47
8.0.270.0030.00317.26
8.0.260.0070.00017.30
8.0.250.0070.00016.98
8.0.240.0070.00017.01
8.0.230.0070.00017.00
8.0.220.0000.00716.94
8.0.210.0000.00716.94
8.0.200.0000.00717.03
8.0.190.0040.00417.02
8.0.180.0030.00516.97
8.0.170.0030.00616.94
8.0.160.0030.00516.95
8.0.150.0040.00416.82
8.0.140.0050.00316.91
8.0.130.0050.00013.32
8.0.120.0050.00216.80
8.0.110.0080.00016.81
8.0.100.0040.00416.86
8.0.90.0040.00416.93
8.0.80.0080.01116.94
8.0.70.0040.00416.72
8.0.60.0040.00416.92
8.0.50.0040.00416.91
8.0.30.0040.01217.09
8.0.20.0130.01017.40
8.0.10.0040.00417.04
8.0.00.0080.01116.89
7.4.330.0060.00015.55
7.4.320.0000.00616.54
7.4.300.0000.01016.64
7.4.290.0030.00516.48
7.4.280.0070.00016.53
7.4.270.0040.00816.46
7.4.260.0070.00016.66
7.4.250.0000.00716.59
7.4.240.0040.00416.55
7.4.230.0000.00716.66
7.4.220.0080.00016.53
7.4.210.0100.00416.59
7.4.200.0030.00316.54
7.4.160.0090.00916.53
7.4.140.0080.01017.86
7.4.130.0040.01416.60
7.4.120.0080.01316.54
7.4.110.0090.00916.39
7.4.100.0070.01016.54
7.4.90.0180.00416.62
7.4.80.0080.01119.39
7.4.70.0070.01016.63
7.4.60.0030.01316.58
7.4.50.0100.00716.40
7.4.40.0110.01116.68
7.4.00.0110.00714.90
7.3.330.0000.00713.36
7.3.320.0000.00513.37
7.3.310.0000.00716.40
7.3.300.0070.00016.39
7.3.290.0030.00316.37
7.3.280.0100.00816.39
7.3.260.0070.01016.50
7.3.240.0090.00816.42
7.3.230.0040.01216.48
7.3.210.0080.01416.46
7.3.200.0110.01116.24
7.3.190.0100.00716.54
7.3.180.0160.00316.48
7.3.170.0100.00716.41
7.3.160.0100.00616.36
7.3.120.0030.01014.97
7.3.110.0110.00714.76
7.3.100.0060.00914.89
7.3.90.0000.01514.80
7.3.80.0070.00714.83
7.3.70.0100.00715.01
7.3.60.0000.01214.88
7.3.50.0100.00614.74
7.3.40.0090.00614.91
7.3.30.0060.00614.78
7.3.20.0040.00916.67
7.3.10.0070.00716.66
7.3.00.0070.00816.64
7.2.330.0120.00616.84
7.2.320.0140.00716.82
7.2.310.0110.01116.79
7.2.300.0030.01416.87
7.2.290.0060.01216.62
7.2.250.0100.01015.29
7.2.240.0030.01415.08
7.2.230.0060.01215.23
7.2.220.0050.00515.24
7.2.210.0110.00315.33
7.2.200.0080.00615.11
7.2.190.0000.01015.22
7.2.180.0060.01215.15
7.2.170.0030.01515.15
7.2.160.0070.01014.97
7.2.150.0000.01416.86
7.2.140.0040.00816.81
7.2.130.0060.00816.87
7.2.120.0060.00817.00
7.2.110.0040.01116.88
7.2.100.0050.00716.88
7.2.90.0090.00516.91
7.2.80.0040.00916.82
7.2.70.0090.00916.29
7.2.60.0080.00816.34
7.2.50.0090.00716.14
7.2.40.0060.00816.27
7.2.30.0140.00516.14
7.2.20.0080.00816.25
7.2.10.0080.00916.34
7.2.00.0100.00616.24
7.1.330.0070.00715.85
7.1.320.0040.01115.90
7.1.310.0040.01115.95
7.1.300.0000.01515.85
7.1.290.0080.00815.89
7.1.280.0060.00615.88
7.1.270.0070.00415.84
7.1.260.0080.00415.65
7.1.250.0080.00615.63
7.1.200.0090.00315.72
7.1.170.0140.01013.66
7.1.160.0100.01313.82
7.1.150.0180.00413.96
7.1.140.0100.01013.99
7.1.130.0240.01013.83
7.1.120.0200.00013.74
7.1.110.0150.00614.04
7.1.100.0180.00314.02
7.1.90.0130.00913.91
7.1.80.0840.00613.83
7.1.70.0100.01013.79
7.1.60.0300.01031.30
7.1.50.0340.01031.50
7.1.40.0320.01031.89
7.1.30.0290.01331.44
7.1.20.0340.01431.75
7.1.10.0210.01213.92
7.1.00.0180.00313.92

preferences:
170.37 ms | 403 KiB | 5 Q