I'm having trouble pre-fixing the single quote ' character. I'm trying to make a simple injection prevention function ...
function injectionProtect($string) {
    $notallowed = array('\'','"','\\');
    $letters=str_split($string);
    foreach($letters as $key => $value) {
        if (array_search($value,$notallowed)>=1) {
            $letters[$key]='\\' . $value;
        }
    }
    $string=implode("",$letters);
    return $string;
}
It works for the \ and " characters, but not the ' character ... Any one know whats going wrong?
I've tried typing the ' as '\'' and "'" but neither works, it just still outputs it as '
 
     
     
    