Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Strip HTML fromMeta Description

Posted on 2013-06-06
3
Medium Priority
?
488 Views
Last Modified: 2013-06-06
I want to use copy from my database for the meta description.

Problem is that because there's link breaks, paragraphs and links in the copy it's not really working. Do you know how I could strip the copy of all of this and just show the text?

This is the php I use to call the text...

<meta name="description" content="<?php echo $row_Recordset1['copy']; ?>">

I could also do with limits the text to 200 characters.
0
Comment
Question by:BrighteyesDesign
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 39225482
Maybe something like this:
<meta name="description" content="<?php echo substr(strip_tags($row_Recordset1['copy']),0,200); ?>">

Open in new window

Obviously since I do not have your data I cannot test it.  Key functions to apply in order:
http://php.net/manual/en/function.strip-tags.php
http://php.net/manual/en/function.substr.php
0
 

Author Closing Comment

by:BrighteyesDesign
ID: 39225558
Perfect, cheers Ray!
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39225905
Thanks for the points! ~Ray
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this article, we’ll look at how to deploy ProxySQL.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

664 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question