3v4l.org

run code in 300+ PHP versions simultaneously
<?php enum Language: int { case English = 1; case SPANISH = 2; public static function getLanguageKey(string $language): int { $reflection = new \ReflectionEnum(Language::class); return $reflection->getCase($language)->getValue()->value; } public static function getLanguageName(int $languageKey): string { $reflection = new \ReflectionEnum(Language::class); $case = array_filter($reflection->getCases(), fn($enum) => $enum->getValue()->value === $languageKey); return $case[0]->getValue()->name; } } $input = 1; Language::getLanguageName($input); // 'English $input = 'English'; Language::getLanguageKey($input); // '1

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.30.0060.01020.11
8.5.20.0120.00720.28
8.5.10.0140.00420.27
8.5.00.0110.01120.11
8.4.180.0120.01019.63
8.4.170.0130.00820.45
8.4.160.0120.01125.66
8.4.150.0070.00516.86
8.4.140.0130.00817.68
8.4.130.0140.00617.57
8.4.120.0060.00320.52
8.4.110.0120.00817.92
8.4.100.0090.01017.77
8.4.90.0120.00720.67
8.4.80.0100.00919.02
8.4.70.0100.01118.75
8.4.60.0130.00718.72
8.4.50.0060.01417.96
8.4.40.0000.00919.35
8.4.30.0130.00720.47
8.4.20.0190.00019.61
8.4.10.0130.00720.54
8.3.300.0100.00920.98
8.3.290.0120.01020.70
8.3.280.0090.01118.66
8.3.270.0190.00916.45
8.3.260.0090.01116.38
8.3.250.0040.00618.96
8.3.240.0090.01116.73
8.3.230.0130.00716.55
8.3.220.0110.00719.13
8.3.210.0080.00418.39
8.3.200.0050.00416.62
8.3.190.0140.00617.11
8.3.180.0060.00820.64
8.3.170.0110.00716.77
8.3.160.0040.01416.36
8.3.150.0090.00918.94
8.3.140.0060.01216.67
8.3.130.0030.00618.44
8.3.120.0110.00018.80
8.3.110.0030.00618.39
8.3.100.0000.00918.23
8.3.50.0190.00018.30
8.2.300.0100.00922.23
8.2.290.0120.00616.80
8.2.280.0050.00418.53
8.2.270.0120.00616.73
8.2.260.0060.00318.86
8.2.250.0080.00018.82
8.2.240.0060.00319.07
8.2.230.0100.01018.11
8.2.220.0080.00018.07
8.1.340.0100.01317.69
8.1.330.0090.00916.34
8.1.320.0070.00216.18
8.1.310.0050.00318.56
8.1.300.0060.00616.34
8.1.30.0050.00317.63

preferences:
43.09 ms | 720 KiB | 5 Q