3v4l.org

run code in 300+ PHP versions simultaneously
<?php $document = new stdClass(); $document->authors = [ [ 'id' => "18141", "userId" => null, "image" => '', 'firstName' => 'John', 'lastName' => 'Inazu', 'publicEmail' => null, 'publicWebsite' => null, 'publicFacebook' => null, 'publicTwitterUsername' => null, 'publicEndnote' => null, 'byline' => 'John Inazu', 'extraData' => null ] ]; doTheThings($document); function doTheThings($document) { $authors = array(); $authorEmails = array(); $authorExtra = array(); $bylineExtra = array(); $documentAuthors = array(); foreach($document->authors as $author) { $documentAuthors []= (array)$author; } foreach($documentAuthors as $key => $author) { $temp = trim(str_replace(array($author['firstName'], $author['lastName']), '', $author['byline'])); if(in_array($temp, $bylineExtra)) { foreach($bylineExtra as $key2 => $value) { if($value == $temp) { $documentAuthors[$key2]['byline'] = trim(str_replace($temp, '', $documentAuthors[$key2]['byline'])); } } } $bylineExtra[$key] = $temp; } foreach($documentAuthors as $key => $author) { if(!empty($author['byline'])) { $authors []= $author['byline']; } else { $authors []= $author['firstName'].' '.$author['lastName']; } $authorEmails []= $author['publicEmail']; //lump all our other author data plus our "extra" author data together $tmp = $author; unset($tmp['firstName']); unset($tmp['lastName']); unset($tmp['publicEmail']); unset($tmp['byline']); unset($tmp['extraData']); $author['extraData'] = array_merge(json_decode(json_encode($author['extraData']), true), $tmp); $authorExtra []= $author['extraData']; } $authorName = implode(', ',$authors); $authorEmails = implode(', ',$authorEmails); echo '<pre>'; print_r($authorName); print_r($authorEmails); print_r($authorExtra); }

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.0150.00018.80
8.3.50.0060.01016.40
8.3.40.0070.00718.88
8.3.30.0100.01018.66
8.3.20.0080.00021.63
8.3.10.0050.00323.53
8.3.00.0040.00423.84
8.2.180.0000.01516.77
8.2.170.0110.00422.96
8.2.160.0070.00722.12
8.2.150.0080.00024.18
8.2.140.0060.00324.66
8.2.130.0000.00821.07
8.2.120.0080.00026.35
8.2.110.0100.00020.38
8.2.100.0060.00618.03
8.2.90.0030.00619.52
8.2.80.0040.00419.77
8.2.70.0030.00617.90
8.2.60.0000.00817.75
8.2.50.0050.00318.10
8.2.40.0050.00320.60
8.2.30.0000.00819.47
8.2.20.0040.00418.09
8.2.10.0040.00417.94
8.2.00.0060.00318.16
8.1.280.0070.00725.92
8.1.270.0040.00423.91
8.1.260.0040.00426.35
8.1.250.0030.00728.09
8.1.240.0060.00324.04
8.1.230.0070.00422.75
8.1.220.0040.00417.74
8.1.210.0040.00418.77
8.1.200.0030.00617.38
8.1.190.0050.00317.35
8.1.180.0030.01018.10
8.1.170.0060.00318.64
8.1.160.0040.00418.91
8.1.150.0000.00720.24
8.1.140.0030.00517.79
8.1.130.0040.00418.95
8.1.120.0000.00717.50
8.1.110.0000.00717.41
8.1.100.0070.00017.38
8.1.90.0000.00717.53
8.1.80.0050.00317.52
8.1.70.0000.00717.52
8.1.60.0030.00617.52
8.1.50.0030.00617.57
8.1.40.0080.00017.53
8.1.30.0000.00817.61
8.1.20.0040.00417.55
8.1.10.0060.00317.57
8.1.00.0060.00317.55
8.0.300.0070.00019.93
8.0.290.0000.00716.75
8.0.280.0030.00318.47
8.0.270.0050.00317.33
8.0.260.0030.00316.90
8.0.250.0000.00817.05
8.0.240.0040.00417.04
8.0.230.0030.00317.04
8.0.220.0000.00716.88
8.0.210.0000.00716.92
8.0.200.0000.00717.09
8.0.190.0040.00417.02
8.0.180.0000.00716.90
8.0.170.0000.00917.02
8.0.160.0040.00417.04
8.0.150.0040.00416.88
8.0.140.0000.00816.83
8.0.130.0000.00613.43
8.0.120.0000.00816.87
8.0.110.0020.00516.78
8.0.100.0070.00016.78
8.0.90.0000.00717.05
8.0.80.0090.00617.01
8.0.70.0050.00216.95
8.0.60.0070.00016.88
8.0.50.0040.00416.87
8.0.30.0090.00917.24
8.0.20.0050.01517.40
8.0.10.0030.00316.97
8.0.00.0110.00616.68
7.4.330.0030.00315.55
7.4.320.0030.00316.61
7.4.300.0070.00016.55
7.4.290.0000.00716.57
7.4.280.0030.00516.54
7.4.270.0040.00416.54
7.4.260.0040.00416.63
7.4.250.0030.00316.59
7.4.240.0040.00416.57
7.4.230.0000.00716.46
7.4.220.0000.00816.53
7.4.210.0100.01016.52
7.4.200.0000.00716.51
7.4.160.0050.01216.61
7.4.140.0110.01217.86
7.4.130.0030.01616.53
7.4.120.0100.00916.55
7.4.110.0000.01816.59
7.4.100.0030.01516.45
7.4.90.0100.00716.64
7.4.80.0100.00719.39
7.4.70.0060.01616.55
7.4.60.0100.00816.64
7.4.50.0100.01016.26
7.4.40.0160.00016.34
7.4.10.0110.00815.14
7.4.00.0080.00915.09
7.3.330.0060.00013.45
7.3.320.0000.00513.33
7.3.310.0070.00016.57
7.3.300.0070.00016.32
7.3.290.0070.01016.47
7.3.280.0070.01216.39
7.3.260.0160.00816.56
7.3.250.0100.00816.57
7.3.240.0100.00716.52
7.3.230.0130.00716.66
7.3.210.0150.00616.46
7.3.200.0040.01216.50
7.3.190.0060.00916.67
7.3.180.0100.00816.38
7.3.170.0070.01016.45
7.3.160.0080.00816.32
7.3.130.0070.01214.93
7.3.120.0020.01415.01
7.3.110.0110.00814.75
7.3.100.0050.01014.79
7.3.90.0110.00715.00
7.3.80.0080.00514.87
7.3.70.0070.00714.86
7.3.60.0050.01214.85
7.3.50.0080.00514.83
7.3.40.0050.00414.74
7.3.30.0110.00114.88
7.3.20.0050.00916.60
7.3.10.0060.00716.68
7.3.00.0050.00616.81
7.2.330.0030.01416.79
7.2.320.0090.00916.71
7.2.310.0140.00516.79
7.2.300.0110.00716.54
7.2.290.0110.01116.53
7.2.260.0080.01115.12
7.2.250.0050.01315.19
7.2.240.0060.00915.21
7.2.230.0030.01215.09
7.2.220.0050.01215.21
7.2.210.0050.00815.09
7.2.200.0080.00615.10
7.2.190.0070.00815.13
7.2.180.0040.00915.18
7.2.170.0080.00615.05
7.2.160.0060.00615.02
7.2.150.0050.01016.80
7.2.140.0030.01117.00
7.2.130.0050.00816.87
7.2.120.0060.00717.01
7.2.110.0070.00616.89
7.2.100.0070.00716.82
7.2.90.0090.00416.89
7.2.80.0050.00916.91
7.2.70.0080.00517.09
7.2.60.0040.00817.00
7.2.50.0070.00816.90
7.2.40.0060.00916.99
7.2.30.0090.00817.03
7.2.20.0080.00917.22
7.2.10.0070.00917.18
7.2.00.0100.00717.19
7.1.330.0050.00915.91
7.1.320.0040.00915.66
7.1.310.0020.00915.84
7.1.300.0030.00915.66
7.1.290.0040.01115.81
7.1.280.0050.00615.95
7.1.270.0070.01015.56
7.1.260.0060.00516.00
7.1.250.0060.00715.83
7.1.240.0060.00815.72
7.1.230.0050.00815.71
7.1.220.0050.00615.91
7.1.210.0070.01015.91
7.1.200.0060.00715.86
7.1.190.0060.01015.86
7.1.180.0060.00715.79
7.1.170.0030.00915.64
7.1.160.0060.00815.67
7.1.150.0070.01116.08
7.1.140.0120.00515.97
7.1.130.0070.01016.17
7.1.120.0080.01015.98
7.1.110.0090.01016.08
7.1.100.0070.00915.96
7.1.90.0080.00915.83
7.1.80.0070.01116.04
7.1.70.0040.01115.63
7.1.60.0150.00721.75
7.1.50.0140.01121.39
7.1.40.0190.00721.33
7.1.30.0340.01221.38
7.1.20.0130.01121.50
7.1.10.0070.01115.48
7.1.00.0110.00615.59
7.0.330.0120.00315.20
7.0.320.0020.00915.33
7.0.310.0100.00315.32
7.0.300.0050.00815.24
7.0.290.0030.00815.26
7.0.280.0020.00915.24
7.0.270.0090.00615.25
7.0.260.0020.01115.34
7.0.250.0080.00215.45
7.0.240.0080.00315.55
7.0.230.0090.00515.25
7.0.220.0060.00815.51
7.0.210.0050.00515.51
7.0.200.0060.00715.41
7.0.190.0050.00515.34
7.0.180.0030.00915.36
7.0.170.0070.00515.46
7.0.160.0050.00515.25
7.0.150.0050.01015.37
7.0.140.0100.00315.55
7.0.130.0050.00715.21
7.0.120.0030.00715.46
7.0.110.0030.00715.40
7.0.100.0050.00815.51
7.0.90.0060.00915.39
7.0.80.0030.00815.34
7.0.70.0050.00915.26
7.0.60.0020.01215.45
7.0.50.0030.00915.63
7.0.40.0050.00913.53
7.0.30.0090.00513.51
7.0.20.0100.00813.58
7.0.10.0070.00713.38
7.0.00.0050.00913.64
5.6.400.0000.01114.48
5.6.390.0070.00714.56
5.6.380.0060.00814.58
5.6.370.0070.00314.58
5.6.360.0050.01014.69
5.6.350.0050.00814.38
5.6.340.0090.00514.37
5.6.330.0030.01014.51
5.6.320.0040.00814.63
5.6.310.0070.00714.49
5.6.300.0080.00614.66
5.6.290.0030.01214.56
5.6.280.0050.00714.56
5.6.270.0030.00814.58
5.6.260.0050.01014.32
5.6.250.0080.00914.72
5.6.240.0110.00514.50
5.6.230.0060.01114.60
5.6.220.0060.00614.45
5.6.210.0050.00714.56
5.6.200.0040.01014.64
5.6.190.0070.00714.44
5.6.180.0060.00814.48
5.6.170.0100.00514.21
5.6.160.0090.00514.26
5.6.150.0030.00614.45
5.6.140.0030.00814.60
5.6.130.0070.00514.47
5.6.120.0060.00814.47
5.6.110.0070.00514.44
5.6.100.0080.00814.42
5.6.90.0050.00914.46
5.6.80.0060.00614.21
5.6.70.0020.01314.32
5.6.60.0090.00614.50
5.6.50.0150.00214.38
5.6.40.0060.00714.27
5.6.30.0090.00714.37
5.6.20.0020.01314.31
5.6.10.0070.00614.23
5.6.00.0070.00614.39

preferences:
48.98 ms | 401 KiB | 5 Q