<?php

function strClean($cadena)

{

    $string = preg_replace(['/\s+/','/^\s|\s$/'],[' ',''], $cadena);

    $string = trim($string);

    $string = stripslashes($string);

    $string = str_ireplace('<script>', '', $string);

    $string = str_ireplace('</script>', '', $string);

    $string = str_ireplace('<script type=>', '', $string);

    $string = str_ireplace('<script src>', '', $string);

    $string = str_ireplace('SELECT * FROM', '', $string);

    $string = str_ireplace('DELETE FROM', '', $string);

    $string = str_ireplace('INSERT INTO', '', $string);

    $string = str_ireplace('SELECT COUNT(*) FROM', '', $string);

    $string = str_ireplace('DROP TABLE', '', $string);

    $string = str_ireplace("OR '1'='1", '', $string);

    $string = str_ireplace('OR ´1´=´1', '', $string);

    $string = str_ireplace('IS NULL', '', $string);

    $string = str_ireplace('LIKE "', '', $string);

    $string = str_ireplace("LIKE '", '', $string);

    $string = str_ireplace('LIKE ´', '', $string);

    $string = str_ireplace('OR "a"="a', '', $string);

    $string = str_ireplace("OR 'a'='a", '', $string);

    $string = str_ireplace('OR ´a´=´a', '', $string);

    $string = str_ireplace('--', '', $string);

    $string = str_ireplace('^', '', $string);

    $string = str_ireplace('[', '', $string);

    $string = str_ireplace(']', '', $string);

    $string = str_ireplace('==', '', $string);

    return $string;

}

function iso8859_to_utf8(string $s): string {
    $s .= $s;
    $len = \strlen($s);

    for ($i = $len >> 1, $j = 0; $i < $len; ++$i, ++$j) {
        switch (true) {
            case $s[$i] < "\x80": $s[$j] = $s[$i]; break;
            case $s[$i] < "\xC0": $s[$j] = "\xC2"; $s[++$j] = $s[$i]; break;
            default: $s[$j] = "\xC3"; $s[++$j] = \chr(\ord($s[$i]) - 64); break;
        }
    }

    return substr($s, 0, $j);
}



?>