Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
|
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 31st, 2005, 08:46 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default Echo / print variable without html code

The subject says it all really- I have variables with html tags inside and I want to only get the text - is there an easy way to do this ?

example:
$Test= Testing 1 2 3
I need something which will do something like:
$Test2= striphtml($Test)

Thank you.
 
Old April 1st, 2005, 04:15 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

Something like that
echo htmlentities("<html><strong>Bold HTML</strong></html>");

Or u may also c the functions around it ( Ofcourse, in PHP Manual, ur she:frnd:D )



 
Old April 1st, 2005, 06:09 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the response- I don't think I asked the question properly :(

Say the variable =
font size="3" face="Arial">Testing 1 2 3

What I need is a system to echo only:
Testing 1 2 3

So I need to remove the HTML code:
 from the variable or find a way to
disable it when echo(ing) the variable.

Any clue?

 
Old April 1st, 2005, 12:30 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Use strip_tags().
http://www.php.net/strip_tags

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
 
Old April 1st, 2005, 01:28 PM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I Guess I won't need this then:
$Ftext1=$Article_Title;
$FText="";
$FT="YES";
$FText3="";

for ($i=0; $i<=100; $i++)
{

$Var1=substr($Ftext1, $i, 1);

if ( $var1 == "<" ) { $FT="NO"; }
if ( $FT=="YES" ) { $FText=$FText3.$var1; }
if ( $var1 == ">" ) { $FT="YES"; }
$FText3=$FText;
}
Cool because for some weird reason my code isn't working - I can finally go home :)
Thanks.







Similar Threads
Thread Thread Starter Forum Replies Last Post
Print all pages of a HTML report ,XSLT 1.0 jhansib4u XSLT 3 January 17th, 2008 11:17 AM
Print html page using window.open manish.sharma04 BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 0 April 1st, 2006 03:20 AM
how to print html data from access database method Classic ASP Databases 2 March 11th, 2005 12:51 PM
Urgent: How to print an html page using C# mrameshchandra General .NET 2 January 5th, 2005 05:05 AM
Print value of a variable to text file SubodhKumar SQL Language 2 December 10th, 2003 03:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.