3v4l.org

run code in 300+ PHP versions simultaneously
<?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);

preferences:
52.15 ms | 402 KiB | 5 Q