thanks for your reply, laserlight. Your point with the tree is quite interesting. Your first tree is what I need I guess, but the numbers in the array are mostly not the same.
What I'm actually doing is scanning PHP Code for function calls and then tracing their variables.
example:
1 $var1 = "test";
2 $var2 = "the ".$var1;
3 $var3 = exec($var2);
will output where it found the function and the traced variables:
found function exec() [3]: $var3 = exec($var2);
2 $var2 = "the ".$var1;
1 $var1 = "test";
if we have the following PHP code to scan:
1 $var1 = "test";
2 $var2 = "the";
3 $var3 = $var1 . $var2;
4 $var4 = "code";
5 $var5 = exec($var3 . $var4);
I would like to have:
found function exec(): 5 $var5 = exec($var3 . $var4);
3 $var3 = $var1 . $var2;
2 $var2 = "test";
1 $var1 = "test"; (hard to accomplish I think)
4 $var4 = "code";
I now that I probably cant always have a correct tree with line numbers only, but since the parameter tracing is recursive too, I dont know if it makes more sense to add the HTML code there.
I hope this is not too confusing, if so, please stick to the first example with the numbers, but consider that these are line numbers and I dont care if the tree is not always 100% correct if there are line numbers equally in some cases.