Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 09-21-2007, 02:48 PM How Do I Do This?
evans123's Avatar
Ultra Talker

Posts: 468
Trades: 0
I would like to delete text within certain tags for example:

HTML Code:
<head>
<title>Hello This Is So Hard! Not!</title>
</head>
<p>hello</p>
But how would i only delete the tags and text in say <p> it will also be dynamic data!
evans123 is offline
Reply With Quote
View Public Profile Visit evans123's homepage!
 
 
Register now for full access!
Old 09-21-2007, 04:20 PM Re: How Do I Do This?
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
A preg is a good idea.

PHP Code:
$string ' lolz <p>this is fun</p> lol';
$patterns[0] = '/<p>(.*?)</p>/';
$replacements[0] = ' ';
echo 
preg_replace($patterns$replacements$string); 
If you want to remove all the tags, use strip_tags
PHP Code:
$string ' lolz <p>this is fun</p> lol';
$string strip_tags($string);

// If you want to allow certain tags use (in this case, <p> and <a>):
$string strip_tags($string'<p><a>'); 
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE

Last edited by rogem002; 09-21-2007 at 04:25 PM..
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 09-21-2007, 05:25 PM Re: How Do I Do This?
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
yea what he said
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Reply     « Reply to How Do I Do This?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.61324 seconds with 12 queries