Strip Function, Not Stripping Everything?

Discussion in 'PHP' started by adamjblakey, Apr 8, 2008.

  1. #1
    Hi,

    I have the following function which does not strip everything i need.

    function StripAll($value) {
     
     	$value = preg_replace('/[\r\n\t]+/', '', $value);
    	$value = preg_replace("/[rn]+[st]*[rn]+/","n",$value); 
    	$value = stripslashes($value);
    	$value = mysql_real_escape_string($value);
    	$value = trim($value);
    	$value = strip_tags($value);
    	$value = str_replace(",", "", $value);
    	$value = str_replace("'", "", $value);
    	$value = str_replace(";", "", $value);
    	$value = str_replace("&", " ", $value);
    	$value = str_replace("(", " ", $value);
    	$value = str_replace(")", " ", $value);
    
    	return $value;
     
     }
    PHP:
    This still leaves in rn , full stops and brackets any ideas what is wrong with the function?

    Cheers,
    Adam
     
    adamjblakey, Apr 8, 2008 IP
  2. Louis11

    Louis11 Active Member

    Messages:
    783
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    70
    #2
    I haven't looked at the code in depth, but just a quick reminder: don't forget grave accents ;)
     
    Louis11, Apr 8, 2008 IP
  3. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #3
    i think there is a problem with regular expression there :) couldnt point it.
    why dont you use a free class like html2txt() function

     
    olddocks, Apr 9, 2008 IP