|
Posted by MrData on 11/08/06 18:39
Hi,
I have a big problem with my recursive function.
This function have the task to find all blocks in the template file out
and put it recursive into a array. hierarchy of the blocks are
important
At first I try to get all the blocks, but the result is wrong.
[php]
function _buildBlocks2($string,$cur_block="")
{
preg_match_all(sprintf($this->s_block,'.*?'),$string,$matches,PREG_SET_ORDER);
foreach ($matches as $match)
{
$temp = array('name' => $match[1]);
if ( preg_match_all(
sprintf($this->s_block,'.*?'),$match[2],$blocks,PREG_SET_ORDER) )
{
$temp['children']=array();
foreach ($blocks as $block)
$temp['children'][]=$this->_buildBlocks2($match[2],$block[1]);
}
}
return $temp;
}
[/php]
I looking forward to this result
Block A
Block B
...||
...Block B1.1
......|| Block B1.1.1
..........|| Block B1.1.1.1
..........|| Block B1.1.1.2
Block C
But this is my current wrong result
Block B
....||
....Block C
....Block C
:(
Navigation:
[Reply to this message]
|