I have an array $tree with this structure :
Array
(
[0] => Array
(
['fichier'] => 'test.xml'
['classes'] => Array
(
[0] => Array
(
['Id'] => '10'
['IdParent'] => 'L'
)
[1] => Array
(
['Id'] => '10-01'
['IdParent'] => '10'
)
...
)
)
[1] => Array
(
['fichier'] => 'test2.xml'
['classes'] => Array
(
[0] => Array
(
['Id'] => '10'
['IdParent'] => 'L'
)
[1] => Array
(
['Id'] => '10-02'
['IdParent'] => '10'
)
...
)
)
)
[2] => Array
(
...
)
...
)
So structure like
L L ...
10 10
10-01 10-02
10-01-01 10-02-02
10-01-02 10-02-03
And i try to make a treeview like :
L
-> 10
-> 10-01
-> 10-01-01
-> 10-01-02
-> 10-02
-> 10-02-02
-> 10-02-03
i wrote a recursive function :
function treeview($tree, $indiceTree, &$prec, $id = 'ICM'){
$indice = 0;
for ($i = ($indiceTree-sizeof($tree)); $i < sizeof($tree); $i++) {
for ($j = 0; $j < sizeof($tree[$i]['classes']); $j++) {
if($tree[$i]['classes'][$j]['IdParent']==$id) {
if (strpos($prec,$tree[$i]['classes'][$j]['Id']) == false) {
echo $tree[$i]['classes'][$j]['Id']; echo "<br><br>";
$prec .= ";".$tree[$i]['classes'][$j]['Id'];
break;
}
treeview($tree, $indiceTree+$indice,$prec, $tree[$i]['classes'][$j]['Id']);
break;
}
}
$indice++;
}
}
The problem is this function never stop. I mean the display result is good but it displayed only when the PHP time out come : Fatal error: Maximum execution time of 60 seconds exceeded
the initial array ($tree) has 142 elements so the execution is really too long to be used in a web app. Function seems to never stop when finish the array. If you can help me with this function. Thank you in advance