Replace tags with space in PHP for SEO Meta Description

0 votes

I am trying to strip tags from HTML in a MySQL database to plain text for an SEO Meta Description. The HTML in the database looks like this:

<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>

I am using the following PHP to format it:

$showseodesc = trim(strip_tags(substr($showseoproduct['text'],0,160)));

This shows the following in the source of the site:

<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" />

Is there any way I can replace any tags (in this case <p>) so there are no spaces?

I am ideally looking for the Meta Description to look like this:

<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" />

Also, am I correct in thinking Google doesn't pick up extra spaces for the Meta Description?

Mar 12, 2022 in Digital Marketing by Kichu
• 19,040 points
1,076 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

The str_replace is enough for this:-

$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>";

echo str_replace(array('<p>', '</p>'), '', $html);

Output:-

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 progressive training product for use when breaking horses.

Hope this helps. 

answered Apr 5, 2022 by narikkadan
• 86,360 points

edited Mar 5

Related Questions In Digital Marketing

0 votes
0 answers

SEO and Django with title and description tags

I have a base.html for the base ...READ MORE

Mar 8, 2022 in Digital Marketing by Kichu
• 19,040 points
943 views
0 votes
1 answer

How to over-ride meta data in Wordpress, using Squirrly SEO

if (is_archive()){ add_filter('sq_title', 'filter_product_wpseo_metadesc'); function filter_product_wpseo_metadesc($wpseo_metadesc){ ...READ MORE

answered Mar 1, 2022 in Digital Marketing by narikkadan
• 86,360 points
1,280 views
0 votes
0 answers

meta tags that are vital for a website

Mar 3, 2022 in Digital Marketing by Kichu
• 19,040 points
618 views
0 votes
0 answers

modify description on Wp All in one seo

live website, it doesn't shows full description ...READ MORE

Mar 3, 2022 in Digital Marketing by Kichu
• 19,040 points
591 views
0 votes
0 answers

Adding microdata or schema.org for breadcrumb SEO in Drupal 7

I'm currently a little confused about microdata ...READ MORE