SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast toytron's Avatar
    Join Date
    Nov 2006
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    cleaning up input with preg_replace

    I'm trying to strip some stuff from userinput with preg_replace but can't find the solution. (checked the manual and this forum without luck)

    My function uses an array of things to replace and this works fine but
    my code for single and double quotes '/\"/','/\'/' does not work.

    Anyone got an idea how I can escape them correctly?

    many thanx

  2. #2
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you want to remove single and double quotes?

    Code:
    $quotes = '/[\'"]/';
    Or replace singles with doubles?

    Code:
    $quotes = '/\'/';
    $replacement = '"';


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •