help with php str_replace

Discussion in 'PHP' started by MrPJH, Jan 8, 2011.

  1. #1
    i am disabling HTML tags and use this code
    $title=str_replace("<p>", "", $title);
    Code (markup):
    but for each tag i am defining in new line like
    
    $job_title=str_replace("<p>", "", $job_title);
    $job_title=str_replace("</p>", "", $job_title);
    $job_title=str_replace("<br>", "", $job_title);
    $job_title=str_replace("<a>", "", $job_title);
    
    Code (markup):
    is there a way to get resolved it in one line so using it all htmls tags will be disabled
    $job_title=str_replace("ONE STRING TO ALL HTML CODES", "", $job_title);
    Code (markup):
    in this way ???
     
    MrPJH, Jan 8, 2011 IP
  2. Cida

    Cida Peon

    Messages:
    6
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    $job_title = strip_tags($job_title);
    
    Code (php):
    Alternately, htmlentities() will convert all special characters to entities, allowing display of tags but not allowing an XSS vulnerability.
     
    Cida, Jan 8, 2011 IP
    MrPJH likes this.
  3. ankit_frenz

    ankit_frenz Active Member

    Messages:
    1,111
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    63
    #3
    strip tags
    preg_replace

    both should help you out.
    Thanks
     
    ankit_frenz, Jan 8, 2011 IP
    MrPJH likes this.