RE: [PHP] RE: ignore html

From: Date: Sun, 16 Mar 2003 22:53:19 +0000
Subject: RE: [PHP] RE: ignore html
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-139879@lists.php.net to get a copy of this message
> hi guys trikky question , i would like to ignore html in content that i am > replacing news lines with page breaks , how is it possible ? at the moment > and > new line like so \r\n in content will be replaced with a <br> but happens > to > work on say tables tags within the content aswell and need to ignore this. You'll have to make your own function that only matches data between <td> and </td> (or whatever you're looking for) and then applies nl2br() only to that section... For example: preg_replace("!<td>(.*)</td>!Ues","nl2br('<td>$1</td>')",$var); will match only what's between <td> and </td> tags and apply nl2br() to the data. It will leave everything else along. Adapt to your needs, there may be better methods... ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/

« previous php.general (#139879) next »