How can I prevent HTML tags from being displayed in a dynamic meta description?

I'll try to keep things simple: I have this dynamic meta description (og for facebook):

<meta property="og:description" content="<?php echo mb_strimwidth(nl2br($return['copete']), 0, 160, '...'); ?>">

      

But when I post this on facebook, the html tags are displayed. Example (as described on Facebook and I had to insert it as coordinated so you can see the html tags)

<h3 style="color:#aaa;font-style:italic;">Las clavitas jugaban la segunda fecha del torneo en el estadio Godoy Cruz en condición de visitante, a la es...

      

The description is ok, they are just html tags that I want to remove.

How can I prevent this?

Thank you so much!

+3


source to share


1 answer


Just use strip_tags () , it will strip all html codes from your string and you should be fine.



+1


source







All Articles