strip_tags()....用空格替换标记,而不是删除它们 [英] strip_tags() .... replace tags by space rather than deleting them

查看:89
本文介绍了strip_tags()....用空格替换标记,而不是删除它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您知道如何使用php用空格字符替换html标签吗?

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

如果我显示

strip_tags('<h1>Foo</h1>bar');

我得到的结果是"foobar",但我需要使单词分开的是"foo bar".

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

推荐答案

尝试一下.

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

这篇关于strip_tags()....用空格替换标记,而不是删除它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆