3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function checkOGRN($ogrn){ if (strlen($ogrn) == 13) { $verify_num = intval(substr($ogrn, 0, 12)); $check_num = intval(substr($ogrn, -1)); $res_num = $verify_num % 11; } elseif (strlen($ogrn) == 15) { $verify_num = intval(substr($ogrn, 0, 14)); $check_num = intval(substr($ogrn, -1)); $res_num = $verify_num % 13; } else return false; if ($res_num > 9) $res_num = $res_num - round($res_num/10)*10; return ($res_num == $check_num); } if(checkOGRN('311333426300044')) echo 'OK'; else echo 'Error';
based on Nrd44
Output for 4.3.0 - 7.1.0
OK