Skip to content Skip to sidebar Skip to footer

Php Regex Breaking Special Characters

var_dump( preg_replace( array( '#[\s\n\\n]*<[\/\s]?(br|/p|/div)[\/\s]?>[\s\n\\n]*#iu', '#\s+#' ), ' ', 'A 19th century Dutch walnut secrétaire à abatta

Solution 1:

If you set your character encoding right, there is no issue. See your code run on eval.in.

Make sure to have this in your html document:

<!DOCTYPE html><html><head><metacharset="utf-8"></head>

And also save your PHP file as UTF-8 encoded. Depending on your editor this might be an option in the "Save As" dialog, or under the "preferences" or "options" menu.

Post a Comment for "Php Regex Breaking Special Characters"