php - How to remove single and double quotes from a string -


When I run a function that contains double quotes through this function, then quoting its quote.

I want to remove them altogether (even a single quote) How can I change the function to do this? Pref_title ($ s) function {$ result = preg_replace ("/ [^ a-zA-Z0-9] + /", "", $ S); Return result; Example: This is the first 'example': thisis030the039firstexample errors: Warning: preg_match_all () [function.preg-match - All]: Unknown modifier '0' in C. Example 2: This is my "second" example return: Iismyquotsecondquotexample Errors: Invalid Express in Xpath

It appears that your original string contained HTML characters for " ( & amp; quot; ), so when you Clear it, you can simply delete & amp; and ; Exclude the remaining string quot .

--- Edit ---

Perhaps the easiest way to remove non-alpha numerical characters HTML characters have to be decoded, then it will run through regular expression, in this situation, the need to re-encode T, you do not need to do it again, but it is worth remembering that you Was the HTML data and now you raw unencoded data.

Example: function string_sanitize ($ s) {$ result = preg_replace ("/ [^ a-zA-Z0-9] + /", "", Html_entity_decode ($ s, ENT_QUOTES)); Return result; }

Note that the ENT_QUOTES function is "convert to both double and single quotes."

Comments