我正在尝试将 mySQL 数据库中的 HTML 标签剥离为用于 SEO 元描述的纯文本。数据库中的 HTML 如下所示:
<p>The Break-ezee is a vital piece of equipment for anyone when breaking horses - As used by Mary King.</p>
<p></p>
<p>The Break-ezee is an all in one progressive training product for use when breaking horses.</p>
我正在使用以下 PHP 对其进行格式化:
$showseodesc = trim(strip_tags(substr($showseoproduct['text'],0,160)));
这显示了网站源代码中的以下内容:
<meta name="description" content="The Break-ezee is a vital piece of equipment for anyone when breaking horses - As used by Mary King.
The Break-ezee is an all in one progressi" />
无论如何我可以替换任何标签(在本例中为
)以便没有空格吗?
理想情况下,我希望元描述看起来像这样:
<meta name="description" content="The Break-ezee is a vital piece of equipment for anyone when breaking horses - As used by Mary King. The Break-ezee is an all in one progressi" />
此外,我认为 Google 不会为元描述选择额外的空间是否正确?
非常感谢您的帮助。
最佳答案
你可以使用 str_replace
$showseodesc = str_replace(array('<p>', '</p>'), '', $showseodesc);
$showseodec = substr($showseoproduct['text'],0, 160);
关于php - 在 PHP 中用空格替换标签以实现 SEO 元描述,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17063032/