preg_match help!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
revbackup
Forum Commoner
Posts: 29
Joined: Tue Jun 09, 2009 1:52 am

preg_match help!

Post by revbackup »

If I have a variable like this:

Code: Select all

 
$html = '<td>
<span onmouseover="_tipon(this)" onmouseout="_tipoff()">
<span class="google-src-text" style="direction: ltr; text-align: left">
1206732400OWYJ
</span>
1206732400OWYJ
</span></td>';
 
and I want to remove the one in red text so that the new variable would contain

Code: Select all

 
$html = '<td>
<span onmouseover="_tipon(this)" onmouseout="_tipoff()">
1206732400OWYJ
</span></td>';
 
How could I possibly do that.??.. I think a preg_match can possibly make it, but I don't know the code and
I dont know that much about preg_match.... Please help me with this... thanks! :D
Last edited by Benjamin on Tue Jun 09, 2009 11:41 pm, edited 1 time in total.
Reason: Added [code=php] tags.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: preg_match help!

Post by requinix »

If you have valid HTML and all the opening/closing tags - which you do - use DOMDocument to remove nodes. It's like using JavaScript.
Post Reply