I read this php code in site php.net
my question How can I know deep level ?
PHP Code:plain
[indent] >> DEB LEVEL=1
deep
[indent] >> >> DEB LEVEL=2
deeper
[/indent]deep
[/indent]plain
PHP Code:<?php
$input = "plain [indent] deep [indent] deeper[/indent]deep[/indent]plain";
function parseTagsRecursive($input)
{
$regex = '#\[indent]((?:[^[]|\[(?!/?indent])|(?R))+)\[/indent]#';
if (is_array($input)) {
$input = '<div style="margin-left: 10px">'.$input[1].'</div>';
}
return preg_replace_callback($regex, 'parseTagsRecursive', $input);
}
$output = parseTagsRecursive($input);
echo $output;
?>




Reply With Quote