note 60379 deleted from function.ereg-replace by nlopess

From: Date: Sat, 07 Jan 2006 10:52:50 +0000
Subject: note 60379 deleted from function.ereg-replace by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-101350@lists.php.net to get a copy of this message
Note Submitter: developer at cornbob dot de ---- I was searching a way to remove all html-tags in a text string, but did not find the right code segment... I have written a little bit code that removes any html-tags, changing BR-Tags in newlines. anyway, hope, it will be usefull for someone function ch_remove_html($txt='') { // call with a string // returns only txt (html tags removed) $toremove = 1; // start loop $txt = ereg_replace("<[/]?br>","\n",$txt); // change to newline $txt_size = strlen($txt); // current length while ($toremove == 1) { $txt = ereg_replace("(.*)<[/]?.*>(.*)","\\1\\2",$txt); // remove if any if ($txt_size == strlen($txt)) { $toremove=0; // if no more html tags avaiable, cancel loop } $txt_size=strlen($txt); // size after any removings } // echo $txt; return $txt; }

« previous php.notes (#101350) next »