Reply to Re: Multi - level parsing

Your name:

Reply:


Posted by Rik on 02/03/07 17:22

Well, another method then previously described, but something I just =

thought of: your idea to process tags only if they don't have nested tag=
s =

in them might work indeed... As long as a normal '[' is strictly forbidd=
en =

in the text itself. Again, without testing, so beware of typing errors, =
or =

other huge mistakes on my part :-)


<?php
/* first, process all self_closing tags */
function process_self_closing(){
//you logic for replacing
var_dump(func_get_args());
}
$string =3D =

preg_replace_callback('#\[([^\]|]+)(?:|([^\]|]+))*/]#','process_self_clo=
sing',$string);

/* match tags that don't have children */
function process_tags((){
//you logic for replacing
var_dump(func_get_args());
}
$count =3D 1;
while($count !=3D 0){
$string =3D =

preg_replace_callback('#\[([^\]|]+)(?:|([^\]|]+))*/]([^\[]*)\[/\1]#','pr=
ocess_tags',$string,-1,$count);
}
?>

Note: count parameter is available since PHP 5.1.0.

-- =

Rik Wasmus

[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

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