3v4l.org

run code in 300+ PHP versions simultaneously
<?php $username = 'test'; $translateWord = 'How are you'; $words = explode(' ', $translateWord); $list = implode(',', array_map(function ($word) { return "'" . strtolower(trim($word)) . "'"; }, $words)); $query = "SELECT LOWER(English) AS English, LOWER(Translation) AS Translation FROM $username WHERE LOWER(English) IN ($list)"; // query table // $result = $connection->query($query); // $rows = $result->fetch_all(); // simulated result $rows = array(array('English' => 'how', 'Translation' => 'como'), array('English' => 'are', 'Translation' => 'son'), array('English' => 'you', 'Translation' => 'tu')); $translation = array(); foreach ($words as $word) { if (($key = array_search(strtolower($word), array_column($rows, 'English'))) !== false) { // match case of result if (strtoupper($word) == $word) { $translation[] = strtoupper($rows[$key]['Translation']); } elseif (ucfirst($word) == $word) { $translation[] = ucfirst($rows[$key]['Translation']); } else { $translation[] = $rows[$key]['Translation']; } } else { // no match, leave alone $translation[] = $word; } } echo $translateWord . " => " . implode(' ', $translation);

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.120.0080.01124.02
8.4.110.0090.01218.86
8.4.100.0150.00918.60
8.4.90.0140.00718.94
8.4.80.0110.01120.33
8.4.70.0130.00820.83
8.4.60.0130.00820.46
8.4.50.0100.00922.31
8.4.40.0100.01019.47
8.4.30.0150.00620.52
8.4.20.0000.02019.68
8.4.10.0090.00619.32
8.3.250.0100.00919.11
8.3.240.0110.00816.35
8.3.230.0090.00716.69
8.3.220.0070.01119.04
8.3.210.0090.01018.46
8.3.200.0050.00316.50
8.3.190.0070.00416.84
8.3.180.0100.01018.83
8.3.170.0130.00617.37
8.3.160.0140.00416.68
8.3.150.0130.00718.47
8.3.140.0070.01116.56
8.3.130.0140.00418.50
8.3.120.0120.00419.15
8.3.110.0000.00818.43
8.3.100.0030.00716.60
8.3.90.0080.00020.32
8.3.80.0060.00616.50
8.3.70.0100.00716.88
8.3.60.0070.00718.43
8.3.50.0110.00823.69
8.3.40.0070.00718.72
8.3.30.0070.01418.84
8.3.20.0030.00621.90
8.3.10.0080.00020.29
8.3.00.0040.00421.90
8.2.290.0140.00720.64
8.2.280.0120.00818.57
8.2.270.0070.01118.45
8.2.260.0080.00017.30
8.2.250.0040.00416.62
8.2.240.0060.00916.60
8.2.230.0000.01420.94
8.2.220.0030.00624.06
8.2.210.0000.00826.77
8.2.200.0090.00018.15
8.2.190.0110.00416.63
8.2.180.0120.00316.32
8.2.170.0140.00322.96
8.2.160.0100.00320.57
8.2.150.0040.00424.18
8.2.140.0050.00224.66
8.2.130.0080.00026.16
8.2.120.0030.00526.16
8.2.110.0060.00321.04
8.2.100.0110.00018.16
8.2.90.0000.00917.63
8.2.80.0000.00818.77
8.2.70.0080.00017.63
8.2.60.0060.00318.05
8.2.50.0040.00718.04
8.2.40.0000.00718.34
8.2.30.0040.00418.03
8.2.20.0040.00418.02
8.2.10.0050.00319.33
8.2.00.0070.00019.28
8.1.330.0120.00821.88
8.1.320.0090.01216.23
8.1.310.0140.00416.79
8.1.300.0060.00916.79
8.1.290.0000.01030.84
8.1.280.0060.00925.92
8.1.270.0040.00420.89
8.1.260.0080.00026.35
8.1.250.0030.00628.09
8.1.240.0040.00422.50
8.1.230.0070.00417.77
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0090.00017.35
8.1.190.0080.00017.22
8.1.180.0040.00418.10
8.1.170.0040.00417.62
8.1.160.0040.00418.95
8.1.150.0050.00218.96
8.1.140.0040.00422.16
8.1.130.0040.00419.28
8.1.120.0000.00817.34
8.1.110.0050.00217.50
8.1.100.0000.00917.41
8.1.90.0040.00417.48
8.1.80.0000.00717.45
8.1.70.0030.00317.48
8.1.60.0040.00417.49
8.1.50.0040.00417.43
8.1.40.0000.00817.39
8.1.30.0040.00417.67
8.1.20.0000.00817.57
8.1.10.0040.00417.53
8.1.00.0080.00017.50
8.0.300.0060.00318.77
8.0.290.0040.00416.63
8.0.280.0030.00318.46
8.0.270.0000.00717.94
8.0.260.0030.00316.87
8.0.250.0050.00217.01
8.0.240.0070.00316.96
8.0.230.0040.00416.96
8.0.220.0000.00716.89
8.0.210.0050.00316.97
8.0.200.0000.00816.97
8.0.190.0030.00516.93
8.0.180.0040.00416.82
8.0.170.0030.00616.80
8.0.160.0030.00516.92
8.0.150.0000.00716.73
8.0.140.0050.00316.79
8.0.130.0050.00313.31
8.0.120.0000.00816.88
8.0.110.0050.00316.74
8.0.100.0000.00716.85
8.0.90.0030.00616.80
8.0.80.0080.01016.89
8.0.70.0000.00716.86
8.0.60.0000.00816.97
8.0.50.0040.00416.90
8.0.30.0100.00717.25
8.0.20.0070.01016.82
8.0.10.0040.00416.92
8.0.00.0070.01016.85
7.4.330.0000.00515.55
7.4.320.0060.00016.42
7.4.300.0030.00616.45
7.4.290.0000.00816.50
7.4.280.0000.00716.61
7.4.270.0070.00016.55
7.4.260.0000.00513.21
7.4.250.0000.00716.57
7.4.240.0010.00616.53
7.4.230.0000.00716.68
7.4.220.0000.00716.58
7.4.210.0090.00816.61
7.4.200.0040.00416.45
7.4.130.0100.01016.63
7.4.120.0100.01016.54
7.4.110.0120.00616.67
7.4.100.0100.00716.42
7.4.90.0170.00016.49
7.4.80.0090.00919.39
7.4.70.0090.01016.48
7.4.60.0070.00816.50
7.4.50.0000.01516.47
7.4.40.0080.00816.41
7.4.10.0040.01514.84
7.4.00.0090.00814.88
7.3.330.0040.00416.45
7.3.320.0060.00013.25
7.3.310.0030.00316.41
7.3.300.0030.00616.25
7.3.290.0100.00616.36
7.3.280.0060.01216.29
7.3.260.0060.01916.45
7.3.240.0080.01016.62
7.3.230.0030.02016.38
7.3.210.0140.00416.57
7.3.200.0090.00616.38
7.3.190.0000.01816.53
7.3.180.0060.01016.53
7.3.170.0040.01316.38
7.3.160.0100.00616.50
7.3.130.0090.00914.67
7.3.120.0060.01114.80
7.3.110.0090.00914.81
7.3.100.0120.00314.77
7.3.90.0070.00914.81
7.3.80.0040.01014.78
7.3.70.0080.00614.74
7.3.60.0070.00614.77
7.3.50.0050.00814.75
7.3.40.0020.01014.69
7.3.30.0090.00714.55
7.3.20.0140.00515.82
7.3.10.0070.00615.55
7.3.00.0040.00815.63
7.2.330.0110.00616.61
7.2.320.0040.01416.43
7.2.310.0030.01316.63
7.2.300.0070.01516.63
7.2.290.0060.01216.71
7.2.260.0180.00014.86
7.2.250.0070.01115.05
7.2.240.0070.00914.89
7.2.230.0050.01214.90
7.2.220.0070.00514.97
7.2.210.0050.00815.01
7.2.200.0040.01115.11
7.2.190.0060.00814.93
7.2.180.0050.01014.96
7.2.170.0110.00514.93
7.2.160.0070.00915.02
7.2.150.0110.00916.06
7.2.140.0100.00816.04
7.2.130.0080.00916.02
7.2.120.0090.00715.79
7.2.110.0040.01015.99
7.2.100.0050.01315.96
7.2.90.0080.00816.05
7.2.80.0080.00815.97
7.2.70.0030.01515.94
7.2.60.0080.01115.80
7.2.50.0050.01315.84
7.2.40.0080.00915.81
7.2.30.0090.00816.17
7.2.20.0060.00815.98
7.2.10.0020.01116.03
7.2.00.0050.01015.65

preferences:
130.91 ms | 403 KiB | 5 Q