Reply to counting tags and writing missing tags

Your name:

Reply:


Posted by Ja NE on 10/26/05 12:11

sometimes people just forget to close formating tag while writing
message in forum (or enywhere else) so I wrote those lines (for <b>, <i>
and <a> tags)

$i_open = substr_count($tekst, "<i>");
$i_close = substr_count($tekst, "</i>");
if($i_open > $i_close) {
$tekst = "$tekst </i>";
}

but... I would like to have proper nesting, ie: if someone write
"<b>some text <i>without closing tags"
and if my script have order like
if($b_open > $b_close)
if($i_open > $i_close)
if($a_open > $a_close)

I will have unproper nesting:
"<b>some text <i>without closing tags </b> </i>"

Is there some method to "see" which tag should came first?

--
Ja NE
http://fotozine.org/?omen=janimir
--

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация