Solved

Strip HTML fromMeta Description

Posted on 2013-06-06
3
478 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 109

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 109

Expert Comment

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

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Loop through multiple arrays 13 27
Help to align the buttons in a row 2 25
Increase the size of the modal in Bootstrap 5 21
PHP Syntax Error 4 25
This article discusses how to create an extensible mechanism for linked drop downs.
Find out what you should include to make the best professional email signature for your organization.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

816 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

8 Experts available now in Live!

Get 1:1 Help Now