tokam tokam - 1 year ago 69
PHP Question

strip_tags() .... replace tags by space rather than deleting them

Do you know how to replace html tags with a space character using php?

If I display


I get as result "foobar" but what I need to keep words separate is "foo bar".

Answer Source

Try this.

preg_replace('#<[^>]+>#', ' ', '<h1>Foo</h1>bar');