Solved

Strip HTML fromMeta Description

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
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)

911 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

22 Experts available now in Live!

Get 1:1 Help Now