3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function dv($rut) { if(strlen($rut)==7); { echo "Rut Incorrecto \"$rut \"."; return; } $rut = strrev($rut); $aux = 1; $s = 0; for ($i = 0; $i < strlen($rut); $i++) { $aux++; $s += intval($rut[$i]) * $aux; if ($aux == 7) { $aux = 1; } } $digit = 11 - $s % 11; if ($digit == 11) { $d = 0; } elseif ($digit == 10) { $d = "K"; } else { $d = $digit; } echo "El digito verificador es \"$d\"."; return; } dv(13372223);
based on ghhH3
Output for 5.3.21 - 7.3.0rc4
Rut Incorrecto "13372223 ".