Solved

Strip HTML fromMeta Description

Posted on 2013-06-06
3
476 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
  • 2
3 Comments
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 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 108

Expert Comment

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

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now