strong-storm Posted August 11, 2004 Report Posted August 11, 2004 Nu vajadzeetu, lai no $comments pazustu visi <i><u><b> </i></u></b>
bubu Posted August 11, 2004 Report Posted August 11, 2004 $newtext = str_replace(array('<i>','<u>','<b>','</i>','</u>','</b>'), array('','','','','',''), $oldtext);
strong-storm Posted August 11, 2004 Author Report Posted August 11, 2004 (edited) nav kaut kaada iebuuveeta f-ja, kas apkautu visus html kodus? Edited August 11, 2004 by strong-storm
bubu Posted August 11, 2004 Report Posted August 11, 2004 (edited) Nu atver manuāli un paskaties tak!!! http://lv.php.net/strip_tags Edited August 11, 2004 by bubu
Venom Posted August 12, 2004 Report Posted August 12, 2004 $newtext = str_replace(array('<i>','<u>','<b>','</i>','</u>','</b>'), array('','','','','',''), $oldtext); $newtext = str_replace(array('<i>','<u>','<b>','</i>','</u>','</b>'),'', $oldtext); $text=preg_replace('<.*>','',$text);
bubu Posted August 12, 2004 Report Posted August 12, 2004 Venom, protams ar preg_replace to var panākt universālāk, bet es jau sākumā domāju, ka cilvēkam vajag tikai šos sešus tagus apkaut :)
Venom Posted August 12, 2004 Report Posted August 12, 2004 Venom, protams ar preg_replace to var panākt universālāk, bet es jau sākumā domāju, ka cilvēkam vajag tikai šos sešus tagus apkaut :) bubu, neattaisnojies ;) tevi es palaboju tikai tajā str_replace variantā, ar to otru parametru, jo If search is an array and replace is a string; then this replacement string is used for every value of search. Vispār es uzrakstīju un turpinu pilnveidot f-ju, kas atstātu tikai atļautos tagus un to atļautos atribūtus, jo strip_tags var atstāt e.g. <b style="height:1000%" onclick="..."></b>.
raivis Posted January 7, 2005 Report Posted January 7, 2005 Man nestrādā $text=preg_replace('<.*>','',$text); bet strādā gan šādi: $text = 'Vai <b>te</b> kāds ir<i>!</i>'; echo preg_replace("'(<.*?>)'",'',$text)
orion Posted January 7, 2005 Report Posted January 7, 2005 hmz, es izmantoju strip_tags(); lai apkarotu visus tagus...
blackhalt Posted January 7, 2005 Report Posted January 7, 2005 (edited) Īstenībā jau filtri tā saucamie kaut kādi jātaisa ;) ~ : http://paste.php.lv/1507 utml.... Edited January 7, 2005 by blackhalt
vik Posted January 14, 2005 Report Posted January 14, 2005 pavisam vienkārši: <?PHP $text = "<b>blablabla</b>blabla<u>blabla</u>"; $from = array("<",">"); $to = array("<",">"); $text = str_replace($from,$to,$text); echo $text; ?>
Venom Posted January 14, 2005 Report Posted January 14, 2005 2vik, tādā gadījumā labāk izmantot htmlspecialchars(), jo < un > zīmes es varu savadīt arī kā oktālās/unicode stringas.
Recommended Posts