Do you know how to replace html tags with a space character using php?
If I display
strip_tags('<h1>Foo</h1>bar');
I get as result "foobar" but what I need to keep words separate is "foo bar".
$string = '<h1>Foo</h1>bar'; $spaceString = str_replace( '<', ' <',$string ); $doubleSpace = strip_tags( $spaceString ); $singleSpace = str_replace( ' ', ' ', $doubleSpace );
Try this.
preg_replace('#<[^>]+>#', ' ', '<h1>Foo</h1>bar');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With