3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getLibItemByName($array,$name){ // avoid global, assign as parameter foreach($array['library'] as $key => $row){ if($name === $row['name']){ return $row; // return the whole subarray } } return false; } // logically rename json to array $array=[ 'library'=> [ ['name'=>'Alan','age'=>5], ['name'=>'Bert','age'=>6], ['name'=>'Chad','age'=>7], ['name'=>'Doug','age'=>8], ['name'=>'Eddy','age'=>9], ['name'=>'Fred','age'=>10] ] ]; var_export(getLibItemByName($array,'Chad')); echo "\n---\n"; var_export(getLibItemByName($array,'Greg')); echo "\n---\n"; if(($index=array_search('Eddy',array_column($array['library'],'name')))!==false){ var_export($array['library'][$index]); }else{ echo 'No match'; }

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.130.0110.00617.74
8.4.120.0070.00320.41
8.4.110.0140.00618.77
8.4.100.0110.00917.83
8.4.90.0060.00618.59
8.4.80.0110.00818.57
8.4.70.0020.00618.19
8.4.60.0170.00418.77
8.4.50.0090.01019.57
8.4.40.0120.00917.65
8.4.30.0060.01319.62
8.4.20.0100.01020.71
8.4.10.0000.00917.86
8.3.260.0100.00916.58
8.3.250.0060.00418.83
8.3.240.0130.00616.63
8.3.230.0070.01216.57
8.3.220.0100.00819.13
8.3.210.0100.00816.67
8.3.200.0030.00516.71
8.3.190.0150.00517.07
8.3.180.0120.00716.79
8.3.170.0120.00619.15
8.3.160.0120.00616.50
8.3.150.0100.01020.56
8.3.140.0030.00616.77
8.3.130.0030.00518.60
8.3.120.0060.00318.86
8.3.110.0000.00720.94
8.3.100.0040.00416.91
8.3.90.0070.01126.77
8.3.80.0060.00316.22
8.3.70.0000.01516.75
8.3.60.0070.01018.43
8.3.50.0110.00217.50
8.3.40.0110.00718.80
8.3.30.0070.00718.69
8.3.20.0050.00321.97
8.3.10.0000.00823.48
8.3.00.0100.00317.93
8.2.290.0050.01120.38
8.2.280.0120.00620.23
8.2.270.0040.01417.13
8.2.260.0140.00318.86
8.2.250.0040.00418.48
8.2.240.0150.00017.32
8.2.230.0030.00522.58
8.2.220.0050.00524.06
8.2.210.0180.00026.77
8.2.200.0060.00316.50
8.2.190.0170.00716.58
8.2.180.0110.00425.92
8.2.170.0090.00918.91
8.2.160.0070.00722.96
8.2.150.0050.00225.66
8.2.140.0040.00424.66
8.2.130.0030.00626.16
8.2.120.0080.00021.00
8.2.110.0040.00422.13
8.2.100.0090.00317.72
8.2.90.0000.00820.67
8.2.80.0040.00417.97
8.2.70.0040.00418.05
8.2.60.0060.00317.93
8.2.50.0000.00818.34
8.2.40.0000.00822.32
8.2.30.0000.00819.39
8.2.20.0070.00018.12
8.2.10.0070.00018.20
8.2.00.0090.00018.04
8.1.330.0100.00821.68
8.1.320.0110.00915.97
8.1.310.0060.01216.82
8.1.300.0140.00017.99
8.1.290.0040.00430.84
8.1.280.0180.00025.92
8.1.270.0040.00424.66
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0170.00022.60
8.1.230.0060.00620.84
8.1.220.0060.00317.79
8.1.210.0000.00818.99
8.1.200.0000.00917.23
8.1.190.0070.00317.22
8.1.180.0050.00218.10
8.1.170.0000.00818.65
8.1.160.0040.00418.77
8.1.150.0000.00720.20
8.1.140.0000.00817.65
8.1.130.0030.00317.34
8.1.120.0060.00317.46
8.1.110.0050.00317.43
8.1.100.0070.00417.37
8.1.90.0050.00317.45
8.1.80.0040.00417.51
8.1.70.0030.00617.39
8.1.60.0030.00517.58
8.1.50.0000.00817.42
8.1.40.0040.00417.48
8.1.30.0060.00317.66
8.1.20.0050.00517.60
8.1.10.0060.00317.56
8.1.00.0040.00417.55
8.0.300.0000.00819.86
8.0.290.0040.00416.75
8.0.280.0070.00018.42
8.0.270.0030.00317.23
8.0.260.0030.00316.73
8.0.250.0070.00016.84
8.0.240.0050.00316.88
8.0.230.0070.00017.03
8.0.220.0000.00716.95
8.0.210.0040.00416.90
8.0.200.0030.00317.02
8.0.190.0070.00016.86
8.0.180.0080.00316.96
8.0.170.0000.00916.88
8.0.160.0000.00716.80
8.0.150.0040.00316.80
8.0.140.0070.00016.85
8.0.130.0060.00013.36
8.0.120.0040.00416.71
8.0.110.0080.00016.82
8.0.100.0080.00016.89
8.0.90.0040.00416.91
8.0.80.0070.00716.97
8.0.70.0000.00816.93
8.0.60.0000.00716.86
8.0.50.0000.00716.90
8.0.30.0080.01017.16
8.0.20.0080.01017.40
8.0.10.0040.00416.86
8.0.00.0100.00816.99
7.4.330.0050.00015.55
7.4.320.0000.00616.66
7.4.300.0030.00316.42
7.4.290.0080.00016.62
7.4.280.0050.00316.51
7.4.270.0030.00316.54
7.4.260.0040.00416.52
7.4.250.0040.00416.59
7.4.240.0040.00416.55
7.4.230.0070.00016.60
7.4.220.0040.00416.51
7.4.210.0060.01016.69
7.4.200.0000.00716.27
7.4.160.0060.01016.46
7.4.150.0170.00317.40
7.4.140.0110.01017.86
7.4.130.0090.00916.77
7.4.120.0110.00816.51
7.4.110.0180.00016.63
7.4.100.0110.00716.55
7.4.90.0130.00616.58
7.4.80.0050.01819.39
7.4.70.0130.00916.66
7.4.60.0160.00316.43
7.4.50.0000.01516.43
7.4.40.0130.00416.38
7.4.10.0130.00314.61
7.4.00.0060.01115.11
7.3.330.0020.00213.17
7.3.320.0060.00013.18
7.3.310.0070.00016.16
7.3.300.0050.00316.32
7.3.290.0040.00416.36
7.3.280.0050.00916.31
7.3.270.0080.00817.40
7.3.260.0090.01016.39
7.3.240.0150.00516.54
7.3.230.0090.00616.34
7.3.210.0130.00716.39
7.3.200.0030.01316.27
7.3.190.0170.00616.41
7.3.180.0060.00916.43
7.3.170.0120.00416.50
7.3.160.0070.01016.58
7.3.130.0040.01514.96
7.3.120.0100.00315.00
7.3.110.0070.01114.99
7.3.100.0100.00314.62
7.3.90.0150.00014.66
7.3.80.0000.01114.97
7.3.70.0080.00414.56
7.3.60.0090.00914.90
7.3.50.0040.00714.85
7.3.40.0000.01014.66
7.3.30.0050.00514.82
7.3.20.0040.00716.33
7.3.10.0060.00816.23
7.3.00.0090.00516.22
7.2.330.0060.01216.78
7.2.320.0090.01216.80
7.2.310.0130.00916.75
7.2.300.0100.00716.68
7.2.290.0090.00916.64
7.2.260.0030.01614.86
7.2.250.0070.01114.97
7.2.240.0090.00615.24
7.2.230.0070.01114.98
7.2.220.0040.01115.30
7.2.210.0070.00714.78
7.2.200.0050.00815.08
7.2.190.0040.00814.80
7.2.180.0060.00614.95
7.2.170.0080.00414.97
7.2.160.0070.00715.18
7.2.150.0110.00316.87
7.2.140.0090.00616.90
7.2.130.0030.00716.71
7.2.120.0060.00616.84
7.2.110.0100.00816.70
7.2.100.0090.00816.82
7.2.90.0120.00716.72
7.2.80.0070.01116.76
7.2.70.0050.01116.79
7.2.60.0060.00816.82
7.2.50.0070.00716.88
7.2.40.0150.00916.67
7.2.30.0090.01116.90
7.2.20.0140.01017.05
7.2.10.0070.01717.16
7.2.00.0090.01217.25
7.1.330.0040.01115.59
7.1.320.0030.01016.00
7.1.310.0090.00615.51
7.1.300.0080.00415.77
7.1.290.0040.00415.77
7.1.280.0030.01415.64
7.1.270.0030.00915.61
7.1.260.0100.00315.96
7.1.250.0050.00715.60
7.1.240.0080.00315.71
7.1.230.0030.01615.82
7.1.220.0110.00615.79
7.1.210.0040.00415.71
7.1.200.0020.00715.76
7.1.190.0100.00315.61
7.1.180.0100.00015.87
7.1.170.0060.00915.72
7.1.160.0060.00815.92
7.1.150.0040.00715.58
7.1.140.0100.01016.44
7.1.130.0090.01316.18
7.1.120.0080.01016.11
7.1.110.0090.01116.01
7.1.100.0090.01016.04
7.1.90.0080.00915.93
7.1.80.0110.00716.08
7.1.70.0090.01015.51
7.1.60.0190.01024.44
7.1.50.0580.01424.23
7.1.40.0200.01624.09
7.1.30.0240.00924.23
7.1.20.0150.01224.13
7.1.10.0090.00515.27
7.1.00.0080.01315.32
7.0.330.0030.00915.11
7.0.320.0070.01115.27
7.0.310.0080.00515.27
7.0.300.0030.01215.30
7.0.290.0080.00415.20
7.0.280.0000.01115.02
7.0.270.0000.01815.48
7.0.260.0070.00715.29
7.0.250.0030.01015.30
7.0.240.0060.00615.32
7.0.230.0030.01015.21
7.0.220.0040.01115.39
7.0.210.0070.00715.02
7.0.200.0030.00715.02
7.0.190.0000.01015.38
7.0.180.0070.00715.37
7.0.170.0120.00315.51
7.0.160.0050.00815.43
7.0.150.0090.00315.35
7.0.140.0070.01015.34
7.0.130.0070.00415.33
7.0.120.0030.01315.15
7.0.110.0030.00515.38
7.0.100.0000.01115.45
7.0.90.0090.00615.27
7.0.80.0030.00915.35
7.0.70.0030.00915.48
7.0.60.0030.00615.34
7.0.50.0060.00915.48
7.0.40.0030.00913.25
7.0.30.0090.00313.48
7.0.20.0030.00913.54
7.0.10.0030.01013.50
7.0.00.0000.01013.22
5.6.400.0080.00514.60
5.6.390.0070.00714.55
5.6.380.0090.00914.34
5.6.370.0060.00614.50
5.6.360.0030.01014.59
5.6.350.0000.01313.99
5.6.340.0080.00314.52
5.6.330.0040.01214.68
5.6.320.0070.00714.56
5.6.310.0060.00614.29
5.6.300.0040.00714.34
5.6.290.0030.01014.46
5.6.280.0040.01114.09
5.6.270.0040.01114.50
5.6.260.0080.00014.30
5.6.250.0030.00814.05
5.6.240.0120.00314.21
5.6.230.0080.00614.16
5.6.220.0050.00514.30
5.6.210.0060.00614.28
5.6.200.0030.01014.11
5.6.190.0070.00714.41
5.6.180.0130.00314.22
5.6.170.0090.00314.28
5.6.160.0070.00714.37
5.6.150.0030.00714.07
5.6.140.0080.00314.42
5.6.130.0060.00614.56
5.6.120.0070.00714.29
5.6.110.0060.00314.34
5.6.100.0070.00314.44
5.6.90.0030.00614.56
5.6.80.0000.01114.13
5.6.70.0040.00814.32
5.6.60.0070.00714.09
5.6.50.0030.00814.25
5.6.40.0030.00514.55
5.6.30.0030.00714.02
5.6.20.0050.00314.20
5.6.10.0100.00314.15
5.6.00.0070.00714.01

preferences:
31.98 ms | 403 KiB | 5 Q