Tuesday 23 January 2018

Restore htmlspecialchars

Restores the characters fixed with the htmlspecialchars() function

function restore_hsc($len){
    $val = str_replace('&', '&', $val);
    $val = str_replace('ö', '�', $val);
    $val = str_replace('ä', '�', $val);
    $val = str_replace('ü', '�', $val);
    $val = str_replace('&lt;', '<', $val);
    $val = str_replace('&gt;', '>', $val);
    $val = str_replace('&quot;', '"', $val);
    return $val;
}

restore_hsc(htmlspecialchars('&lt;b&gt;test&lt;/b&gt;'));

0 comments:

Post a Comment