3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isPalindrome(string &$str): bool { $regex = <<<REGEX / ^ #start of string ( #start capture group 1 ( #start capture group 2 . #match any non-newline character ) #end capture group2 (?1) #repeat the expression of capture group 1 \2 #match the character from capture group 2 | #or .? #the middle character (if odd length input string) or no character (if even length input string) ) #end capture group 1 $ #end of string /x REGEX; return (bool) preg_match($regex, $str); } function sanitizePalindrome(&$str) { return preg_replace('/[^a-z]+/', '', strtolower($str)); } $tests = [ '', 'radar', 'f', 'neveroddoreven', 'foo', 'palindrome', 'Red rum, sir, is murder' ]; foreach ($tests as $test) { $test = sanitizePalindrome($test); // this is optional printf("%20s : %s\n", $test, json_encode(isPalindrome($test))); }

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.0080.01016.87
8.5.00.0130.00920.19
8.4.150.0020.00014.05
8.4.140.0110.01017.79
8.4.130.0140.00717.77
8.4.120.0070.01223.99
8.4.110.0130.00722.54
8.4.100.0090.01118.85
8.4.90.0090.01019.00
8.4.80.0120.00918.75
8.4.70.0070.00918.02
8.4.60.0120.00919.04
8.4.50.0070.00218.70
8.4.40.0100.01017.68
8.4.30.0190.00018.73
8.4.20.0120.00918.06
8.4.10.0060.00319.73
8.3.280.0060.00318.57
8.3.270.0090.01316.67
8.3.260.0130.00516.82
8.3.250.0030.00418.93
8.3.240.0100.00816.94
8.3.230.0150.00618.91
8.3.220.0070.01118.99
8.3.210.0080.00816.71
8.3.200.0080.01116.58
8.3.190.0090.00917.26
8.3.180.0090.01017.22
8.3.170.0100.01020.68
8.3.160.0070.01117.22
8.3.150.0110.00719.10
8.3.140.0120.00616.65
8.3.130.0060.00318.71
8.3.120.0080.00019.08
8.3.110.0090.00620.94
8.3.100.0120.00616.88
8.3.90.0040.01126.77
8.3.80.0030.00617.97
8.3.70.0120.00916.73
8.3.60.0140.00718.41
8.3.50.0160.00616.68
8.3.40.0110.00722.00
8.3.30.0110.00420.25
8.3.20.0040.01525.66
8.3.10.0100.01025.66
8.3.00.0190.00025.66
8.2.290.0130.00520.59
8.2.280.0120.00818.76
8.2.270.0070.01317.07
8.2.260.0070.01116.63
8.2.250.0080.00016.87
8.2.240.0060.00317.38
8.2.230.0040.00422.58
8.2.220.0140.00524.06
8.2.210.0070.00726.77
8.2.200.0040.00416.63
8.2.190.0150.00316.88
8.2.180.0150.00616.88
8.2.170.0100.00718.97
8.2.160.0110.00322.96
8.2.150.0090.00925.66
8.2.140.0100.01025.66
8.2.130.0100.01025.66
8.2.120.0060.01025.66
8.2.110.0150.00325.66
8.2.100.0160.00325.66
8.2.90.0130.00725.66
8.2.80.0090.00625.66
8.2.70.0090.00625.66
8.2.60.0090.00625.66
8.2.50.0160.00325.66
8.2.40.0060.01225.66
8.2.30.0070.01025.66
8.2.20.0150.00025.66
8.2.10.0080.00825.66
8.2.00.0070.00725.66
8.1.330.0080.01022.23
8.1.320.0120.00716.13
8.1.310.0120.00618.61
8.1.300.0100.00018.49
8.1.290.0090.00030.84
8.1.280.0040.01125.92
8.1.270.0000.00825.66
8.1.260.0000.00825.66
8.1.250.0070.00725.66
8.1.240.0060.00325.66
8.1.230.0040.00425.66
8.1.220.0040.00425.66
8.1.210.0060.00325.66
8.1.200.0050.00325.66
8.1.190.0070.00725.66
8.1.180.0070.00725.66
8.1.170.0130.00325.66
8.1.160.0040.00425.66
8.1.150.0110.00425.66
8.1.140.0040.01125.66
8.1.130.0120.00325.66
8.1.120.0120.00325.66
8.1.110.0040.01125.66
8.1.100.0100.00325.66
8.1.90.0180.00025.66
8.1.80.0090.00925.66
8.1.70.0070.01125.66
8.1.60.0090.00025.66
8.1.50.0040.01525.66
8.1.40.0070.01125.66
8.1.30.0070.01025.66
8.1.20.0080.00825.66
8.1.10.0060.00325.66
8.1.00.0090.00025.66

preferences:
87.41 ms | 403 KiB | 5 Q