3v4l.org

run code in 300+ PHP versions simultaneously
<?php function checkIBAN(string $iban): bool { // Normalize input (remove spaces and make uppercase) $iban = strtoupper(str_replace(' ', '', $iban)); if (!preg_match('/^([A-Z]{2})(\d{2})([A-Z\d]{1,30})$/', $iban, $segments)) { return false; } [, $country, $check, $account] = $segments; $digits = str_split(strtr($account . $country, array_combine(range('A', 'Z'), range(10, 35))) . '00'); $first = array_shift($digits); $checksum = array_reduce( $digits, function ($carry, $int) { $carry = ($carry * 10 + (int)$int) % 97; return $carry; }, (int)$first ); return (98 - $checksum) == $check; } var_export(checkIBAN('GB29NWBK60161331926819'));
Output for git.master, git.master_jit, rfc.property-hooks
true

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
57.12 ms | 401 KiB | 8 Q