Hi there,
I have a directory listing function that runs through a given dir and dumps results into an array thus:
[6] => Array
(
[level] => 7
[path] => /home/###/###/###/###/###/###
[name] => includes
[kind] => dir
[mod_time] => 1185786462
[content] => Array
(
[0] => Array
(
[level] => 8
[path] => /home/###/###/###/###/###/###/###
[name] => functions
[kind] => dir
[mod_time] => 1185786464
[content] => Array
(
[0] => Array
(
[level] => 9
[path] => /home/###/###/###/###/###/###/###/functions.php
[name] => functions.php
[kind] => php
[mod_time] => 1185786464
[size] => 1402
)
)
)
I need to find some way to number each array in the following format:
1
1.1
1.2
1.2.1
1.2.2
2
2.1
2.2
2.2.1
2.2.2
etc etc
I have found a nice function that recursively goes through and displays them in an ordered list, which is this:
function listTree( $tree=array(), $spacer="\t", $level=0) {
if( !is_int( $level ) ) {
$level = 0;
}
$level++;
if( $level == 1 ) {
$out .= '<ol>';
}
foreach( $tree as $key=>$val ) {
$out .= "\n".str_repeat( $spacer, $level ).'<li>';
$out .= $val['name'];
if( $val['content'] ) {
$out .= "\n".str_repeat( $spacer, $level+1 ).'<ol>';
$out .= listTree( $val['content'], $spacer, $level+1);
$out .= "\n".str_repeat( $spacer, $level+1 ).'</ol>';
$out .= "\n".str_repeat( $spacer, $level ).'</li>';
}
else {
$out .= '</li>';
}
}
if( $level == 1 ) {
$out .= "\n".'</ol>';
}
return $out;
}
But I just can't get my head round generting the numbering scheme im after...
I've been banging my head against the wall on this nd any help would be a greatully recieved!
TIA,
d.