php-general Digest 16 Aug 2012 19:39:39 -0000 Issue 7925

Topics (messages 318717 through 318724):

Re: Two ways to obtain an object property
        318717 by: phplist

Display Array Tree as Menu - Can't figure out how to find depth with something 
over 2 levels
        318718 by: Tristan
        318719 by: Volmar Machado
        318720 by: Tristan
        318721 by: David OBrien
        318722 by: Tristan
        318724 by: Tommy Pham

Re: Display Array Tree as Menu - Can't figure out how to find depth with 
something over 2 levels : ANSWERED
        318723 by: Tristan

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On 08/15/2012 11:28 AM, phplist wrote:
This relates to a minor dilemma I come across from time and time, and
I'm looking for advice [...]

Within a site I have a User object, and within page code would like to
have
if ($crntUser->isASubscriber) {...}
[...]
if ($crntUser->isASubscriber()) {...}
[...]
Is either of these approaches preferable, or does it simply not matter?


Thanks to all who responded. Inevitably the answer is "it depends" but I've now got a much better feel about how to decide.

Roddie Grant

--- End Message ---
--- Begin Message ---
I can't for the life of me figure out how to find the depth of the array
that I'm looping through to output tabs or indentations to the display for
each depth. The entries also have section postition if you can figure out
how to include that within each depth of the results I will buy you a case
of beer.

I was hoping to do something like...

foreach($trees as $tree){
    if($tree['current_depth'] == 0){
echo $tree['menu_item'];
    } else if($tree['current_depth'] == 1){
echo 'indentation'.$tree['menu_item'];
    } else if($tree['current_depth'] == 2){
echo 'indentation - indentation'.$tree['menu_item'];
    }
}


Or maybe even like this...

foreach($trees as $tree){
// output   the amount of times current_depth equals
echo str_repeat(" ", $tree['current_depth'])
}

I have my $tree structure as:

[16] => Array
    (
        [section_id] => 21
        [section_parent_id] => 0
        [section_pos] => 30
        [section_name] => Resource Center
        [has_order] => 1
        [section_has_hierarchy] => 1
        [total_entries] => 35
        [children] => Array
            (
                [0] => Array
                    (
                        [section_id] => 38
                        [section_parent_id] => 21
                        [section_pos] => 31
                        [section_name] => Resource Center
                        [has_order] => 1
                        [section_has_hierarchy] => 1
                        [total_entries] => 35
                        [children] => Array

                            (
                                [0] => Array
                                    (
                                        [section_id] => 39
                                        [section_parent_id] => 38
                                        [section_pos] => 32
                                        [section_name] => Resource Center
                                        [has_order] => 1
                                        [section_has_hierarchy] => 1
                                        [total_entries] => 35
                                    )

                                [1] => Array
                                    (
                                        [section_id] => 40
                                        [section_parent_id] => 38
                                        [section_pos] => 33
                                        [section_name] => Resource Center
                                        [has_order] => 1
                                        [section_has_hierarchy] => 1
                                        [total_entries] => 35
                                    )
                            )




[19] => Array
    (
        [section_id] => 26
        [section_parent_id] => 0
        [section_pos] => 45
        [section_name] => Resource Center
        [has_order] => 1
        [section_has_hierarchy] => 1
        [total_entries] => 55
        [children] => Array
            (
                [0] => Array
                    (
                        [section_id] => 27
                        [section_parent_id] => 26
                        [section_pos] => 46
                        [section_name] => Newsletters Intro
                        [has_order] => 0
                        [section_has_hierarchy] => 1
                        [total_entries] => 1
                    )

            )

    )

--- End Message ---
--- Begin Message ---
http://www.php.net/manual/es/function.array-walk-recursive.php

2012/8/16 Tristan <sunnrun...@gmail.com>:
> I can't for the life of me figure out how to find the depth of the array
> that I'm looping through to output tabs or indentations to the display for
> each depth. The entries also have section postition if you can figure out
> how to include that within each depth of the results I will buy you a case
> of beer.
>
> I was hoping to do something like...
>
> foreach($trees as $tree){
>     if($tree['current_depth'] == 0){
> echo $tree['menu_item'];
>     } else if($tree['current_depth'] == 1){
> echo 'indentation'.$tree['menu_item'];
>     } else if($tree['current_depth'] == 2){
> echo 'indentation - indentation'.$tree['menu_item'];
>     }
> }
>
>
> Or maybe even like this...
>
> foreach($trees as $tree){
> // output &nbsp; the amount of times current_depth equals
> echo str_repeat("&nbsp;", $tree['current_depth'])
> }
>
> I have my $tree structure as:
>
> [16] => Array
>     (
>         [section_id] => 21
>         [section_parent_id] => 0
>         [section_pos] => 30
>         [section_name] => Resource Center
>         [has_order] => 1
>         [section_has_hierarchy] => 1
>         [total_entries] => 35
>         [children] => Array
>             (
>                 [0] => Array
>                     (
>                         [section_id] => 38
>                         [section_parent_id] => 21
>                         [section_pos] => 31
>                         [section_name] => Resource Center
>                         [has_order] => 1
>                         [section_has_hierarchy] => 1
>                         [total_entries] => 35
>                         [children] => Array
>
>                             (
>                                 [0] => Array
>                                     (
>                                         [section_id] => 39
>                                         [section_parent_id] => 38
>                                         [section_pos] => 32
>                                         [section_name] => Resource Center
>                                         [has_order] => 1
>                                         [section_has_hierarchy] => 1
>                                         [total_entries] => 35
>                                     )
>
>                                 [1] => Array
>                                     (
>                                         [section_id] => 40
>                                         [section_parent_id] => 38
>                                         [section_pos] => 33
>                                         [section_name] => Resource Center
>                                         [has_order] => 1
>                                         [section_has_hierarchy] => 1
>                                         [total_entries] => 35
>                                     )
>                             )
>
>
>
>
> [19] => Array
>     (
>         [section_id] => 26
>         [section_parent_id] => 0
>         [section_pos] => 45
>         [section_name] => Resource Center
>         [has_order] => 1
>         [section_has_hierarchy] => 1
>         [total_entries] => 55
>         [children] => Array
>             (
>                 [0] => Array
>                     (
>                         [section_id] => 27
>                         [section_parent_id] => 26
>                         [section_pos] => 46
>                         [section_name] => Newsletters Intro
>                         [has_order] => 0
>                         [section_has_hierarchy] => 1
>                         [total_entries] => 1
>                     )
>
>             )
>
>     )

--- End Message ---
--- Begin Message ---
Yeah I saw that but, I still can't figure out how to know which depth it's
at? I've spent about 8 hours on it trying all kinds of things but my logic
ends up failing.


On Thu, Aug 16, 2012 at 11:06 AM, Volmar Machado <qi.vol...@gmail.com>wrote:

> http://www.php.net/manual/es/function.array-walk-recursive.php
>
> 2012/8/16 Tristan <sunnrun...@gmail.com>:
> > I can't for the life of me figure out how to find the depth of the array
> > that I'm looping through to output tabs or indentations to the display
> for
> > each depth. The entries also have section postition if you can figure out
> > how to include that within each depth of the results I will buy you a
> case
> > of beer.
> >
> > I was hoping to do something like...
> >
> > foreach($trees as $tree){
> >     if($tree['current_depth'] == 0){
> > echo $tree['menu_item'];
> >     } else if($tree['current_depth'] == 1){
> > echo 'indentation'.$tree['menu_item'];
> >     } else if($tree['current_depth'] == 2){
> > echo 'indentation - indentation'.$tree['menu_item'];
> >     }
> > }
> >
> >
> > Or maybe even like this...
> >
> > foreach($trees as $tree){
> > // output &nbsp; the amount of times current_depth equals
> > echo str_repeat("&nbsp;", $tree['current_depth'])
> > }
> >
> > I have my $tree structure as:
> >
> > [16] => Array
> >     (
> >         [section_id] => 21
> >         [section_parent_id] => 0
> >         [section_pos] => 30
> >         [section_name] => Resource Center
> >         [has_order] => 1
> >         [section_has_hierarchy] => 1
> >         [total_entries] => 35
> >         [children] => Array
> >             (
> >                 [0] => Array
> >                     (
> >                         [section_id] => 38
> >                         [section_parent_id] => 21
> >                         [section_pos] => 31
> >                         [section_name] => Resource Center
> >                         [has_order] => 1
> >                         [section_has_hierarchy] => 1
> >                         [total_entries] => 35
> >                         [children] => Array
> >
> >                             (
> >                                 [0] => Array
> >                                     (
> >                                         [section_id] => 39
> >                                         [section_parent_id] => 38
> >                                         [section_pos] => 32
> >                                         [section_name] => Resource Center
> >                                         [has_order] => 1
> >                                         [section_has_hierarchy] => 1
> >                                         [total_entries] => 35
> >                                     )
> >
> >                                 [1] => Array
> >                                     (
> >                                         [section_id] => 40
> >                                         [section_parent_id] => 38
> >                                         [section_pos] => 33
> >                                         [section_name] => Resource Center
> >                                         [has_order] => 1
> >                                         [section_has_hierarchy] => 1
> >                                         [total_entries] => 35
> >                                     )
> >                             )
> >
> >
> >
> >
> > [19] => Array
> >     (
> >         [section_id] => 26
> >         [section_parent_id] => 0
> >         [section_pos] => 45
> >         [section_name] => Resource Center
> >         [has_order] => 1
> >         [section_has_hierarchy] => 1
> >         [total_entries] => 55
> >         [children] => Array
> >             (
> >                 [0] => Array
> >                     (
> >                         [section_id] => 27
> >                         [section_parent_id] => 26
> >                         [section_pos] => 46
> >                         [section_name] => Newsletters Intro
> >                         [has_order] => 0
> >                         [section_has_hierarchy] => 1
> >                         [total_entries] => 1
> >                     )
> >
> >             )
> >
> >     )
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On Thu, Aug 16, 2012 at 12:40 PM, Tristan <sunnrun...@gmail.com> wrote:

> I can't for the life of me figure out how to find the depth of the array
> that I'm looping through to output tabs or indentations to the display for
> each depth. The entries also have section postition if you can figure out
> how to include that within each depth of the results I will buy you a case
> of beer.
>
> I was hoping to do something like...
>
> foreach($trees as $tree){
>     if($tree['current_depth'] == 0){
> echo $tree['menu_item'];
>     } else if($tree['current_depth'] == 1){
> echo 'indentation'.$tree['menu_item'];
>     } else if($tree['current_depth'] == 2){
> echo 'indentation - indentation'.$tree['menu_item'];
>     }
> }
>
>
> Or maybe even like this...
>
> foreach($trees as $tree){
> // output &nbsp; the amount of times current_depth equals
> echo str_repeat("&nbsp;", $tree['current_depth'])
> }
>
> I have my $tree structure as:
>
> [16] => Array
>     (
>         [section_id] => 21
>         [section_parent_id] => 0
>         [section_pos] => 30
>         [section_name] => Resource Center
>         [has_order] => 1
>         [section_has_hierarchy] => 1
>         [total_entries] => 35
>         [children] => Array
>             (
>                 [0] => Array
>                     (
>                         [section_id] => 38
>                         [section_parent_id] => 21
>                         [section_pos] => 31
>                         [section_name] => Resource Center
>                         [has_order] => 1
>                         [section_has_hierarchy] => 1
>                         [total_entries] => 35
>                         [children] => Array
>
>                             (
>                                 [0] => Array
>                                     (
>                                         [section_id] => 39
>                                         [section_parent_id] => 38
>                                         [section_pos] => 32
>                                         [section_name] => Resource Center
>                                         [has_order] => 1
>                                         [section_has_hierarchy] => 1
>                                         [total_entries] => 35
>                                     )
>
>                                 [1] => Array
>                                     (
>                                         [section_id] => 40
>                                         [section_parent_id] => 38
>                                         [section_pos] => 33
>                                         [section_name] => Resource Center
>                                         [has_order] => 1
>                                         [section_has_hierarchy] => 1
>                                         [total_entries] => 35
>                                     )
>                             )
>
>
>
>
> [19] => Array
>     (
>         [section_id] => 26
>         [section_parent_id] => 0
>         [section_pos] => 45
>         [section_name] => Resource Center
>         [has_order] => 1
>         [section_has_hierarchy] => 1
>         [total_entries] => 55
>         [children] => Array
>             (
>                 [0] => Array
>                     (
>                         [section_id] => 27
>                         [section_parent_id] => 26
>                         [section_pos] => 46
>                         [section_name] => Newsletters Intro
>                         [has_order] => 0
>                         [section_has_hierarchy] => 1
>                         [total_entries] => 1
>                     )
>
>             )
>
>     )
>


maybe something like this

in the foreach
if parent = 0 then level = 0;
if haschilden is true increment level;

--- End Message ---
--- Begin Message ---
Thanks David, Here's my tree creation. I'm trying to either put depth count
on each array or run through the tree and figure it out after. I just can't
figure out where to put it :D

Great very lightweight script to create a tree from parent id and id if you
want to save this one for yourself btw.

function createTree(&$list, $parent){
    $tree = array();
//$depth = 0;
    foreach ($parent as $k=>$l){
//echo $k.'<br />';
        if(isset($list[$l['section_id']])){
//echo $k.'<br />';
$l['depth'] = $k;
            $l['children'] = createTree($list, $list[$l['section_id']]);
        } else {
$l['depth'] = 0;
}
        $tree[] = $l;
    }
    return $tree;
}

$arr = $dashSections;

$new = array();
foreach ($arr as $a){
    $new[$a['section_parent_id']][] = $a;
}

// CREATE THE TREE
$tree = createTree($new, $new[0]);
//echo count($tree);
//print_r($tree);



On Thu, Aug 16, 2012 at 11:36 AM, David OBrien <dgobr...@gmail.com> wrote:

> On Thu, Aug 16, 2012 at 12:40 PM, Tristan <sunnrun...@gmail.com> wrote:
>
>> I can't for the life of me figure out how to find the depth of the array
>> that I'm looping through to output tabs or indentations to the display for
>> each depth. The entries also have section postition if you can figure out
>> how to include that within each depth of the results I will buy you a case
>> of beer.
>>
>> I was hoping to do something like...
>>
>> foreach($trees as $tree){
>>     if($tree['current_depth'] == 0){
>> echo $tree['menu_item'];
>>     } else if($tree['current_depth'] == 1){
>> echo 'indentation'.$tree['menu_item'];
>>     } else if($tree['current_depth'] == 2){
>> echo 'indentation - indentation'.$tree['menu_item'];
>>     }
>> }
>>
>>
>> Or maybe even like this...
>>
>> foreach($trees as $tree){
>> // output &nbsp; the amount of times current_depth equals
>> echo str_repeat("&nbsp;", $tree['current_depth'])
>> }
>>
>> I have my $tree structure as:
>>
>> [16] => Array
>>     (
>>         [section_id] => 21
>>         [section_parent_id] => 0
>>         [section_pos] => 30
>>         [section_name] => Resource Center
>>         [has_order] => 1
>>         [section_has_hierarchy] => 1
>>         [total_entries] => 35
>>         [children] => Array
>>             (
>>                 [0] => Array
>>                     (
>>                         [section_id] => 38
>>                         [section_parent_id] => 21
>>                         [section_pos] => 31
>>                         [section_name] => Resource Center
>>                         [has_order] => 1
>>                         [section_has_hierarchy] => 1
>>                         [total_entries] => 35
>>                         [children] => Array
>>
>>                             (
>>                                 [0] => Array
>>                                     (
>>                                         [section_id] => 39
>>                                         [section_parent_id] => 38
>>                                         [section_pos] => 32
>>                                         [section_name] => Resource Center
>>                                         [has_order] => 1
>>                                         [section_has_hierarchy] => 1
>>                                         [total_entries] => 35
>>                                     )
>>
>>                                 [1] => Array
>>                                     (
>>                                         [section_id] => 40
>>                                         [section_parent_id] => 38
>>                                         [section_pos] => 33
>>                                         [section_name] => Resource Center
>>                                         [has_order] => 1
>>                                         [section_has_hierarchy] => 1
>>                                         [total_entries] => 35
>>                                     )
>>                             )
>>
>>
>>
>>
>> [19] => Array
>>     (
>>         [section_id] => 26
>>         [section_parent_id] => 0
>>         [section_pos] => 45
>>         [section_name] => Resource Center
>>         [has_order] => 1
>>         [section_has_hierarchy] => 1
>>         [total_entries] => 55
>>         [children] => Array
>>             (
>>                 [0] => Array
>>                     (
>>                         [section_id] => 27
>>                         [section_parent_id] => 26
>>                         [section_pos] => 46
>>                         [section_name] => Newsletters Intro
>>                         [has_order] => 0
>>                         [section_has_hierarchy] => 1
>>                         [total_entries] => 1
>>                     )
>>
>>             )
>>
>>     )
>>
>
>
> maybe something like this
>
> in the foreach
> if parent = 0 then level = 0;
> if haschilden is true increment level;
>
>

--- End Message ---
--- Begin Message ---
On Thu, Aug 16, 2012 at 11:05 AM, Tristan <sunnrun...@gmail.com> wrote:
> Thanks David, Here's my tree creation. I'm trying to either put depth count
> on each array or run through the tree and figure it out after. I just can't
> figure out where to put it :D
>
> Great very lightweight script to create a tree from parent id and id if you
> want to save this one for yourself btw.
>
> function createTree(&$list, $parent){
>     $tree = array();
> //$depth = 0;
>     foreach ($parent as $k=>$l){
> //echo $k.'<br />';
>         if(isset($list[$l['section_id']])){
> //echo $k.'<br />';
> $l['depth'] = $k;
>             $l['children'] = createTree($list, $list[$l['section_id']]);
>         } else {
> $l['depth'] = 0;
> }
>         $tree[] = $l;
>     }
>     return $tree;
> }
>
> $arr = $dashSections;
>
> $new = array();
> foreach ($arr as $a){
>     $new[$a['section_parent_id']][] = $a;
> }
>
> // CREATE THE TREE
> $tree = createTree($new, $new[0]);
> //echo count($tree);
> //print_r($tree);
>
>
>
> On Thu, Aug 16, 2012 at 11:36 AM, David OBrien <dgobr...@gmail.com> wrote:
>
>> On Thu, Aug 16, 2012 at 12:40 PM, Tristan <sunnrun...@gmail.com> wrote:
>>
>>> I can't for the life of me figure out how to find the depth of the array
>>> that I'm looping through to output tabs or indentations to the display for
>>> each depth. The entries also have section postition if you can figure out
>>> how to include that within each depth of the results I will buy you a case
>>> of beer.
>>>
>>> I was hoping to do something like...
>>>
>>> foreach($trees as $tree){
>>>     if($tree['current_depth'] == 0){
>>> echo $tree['menu_item'];
>>>     } else if($tree['current_depth'] == 1){
>>> echo 'indentation'.$tree['menu_item'];
>>>     } else if($tree['current_depth'] == 2){
>>> echo 'indentation - indentation'.$tree['menu_item'];
>>>     }
>>> }
>>>
>>>
>>> Or maybe even like this...
>>>
>>> foreach($trees as $tree){
>>> // output &nbsp; the amount of times current_depth equals
>>> echo str_repeat("&nbsp;", $tree['current_depth'])
>>> }
>>>
>>> I have my $tree structure as:
>>>
>>> [16] => Array
>>>     (
>>>         [section_id] => 21
>>>         [section_parent_id] => 0
>>>         [section_pos] => 30
>>>         [section_name] => Resource Center
>>>         [has_order] => 1
>>>         [section_has_hierarchy] => 1
>>>         [total_entries] => 35
>>>         [children] => Array
>>>             (
>>>                 [0] => Array
>>>                     (
>>>                         [section_id] => 38
>>>                         [section_parent_id] => 21
>>>                         [section_pos] => 31
>>>                         [section_name] => Resource Center
>>>                         [has_order] => 1
>>>                         [section_has_hierarchy] => 1
>>>                         [total_entries] => 35
>>>                         [children] => Array
>>>
>>>                             (
>>>                                 [0] => Array
>>>                                     (
>>>                                         [section_id] => 39
>>>                                         [section_parent_id] => 38
>>>                                         [section_pos] => 32
>>>                                         [section_name] => Resource Center
>>>                                         [has_order] => 1
>>>                                         [section_has_hierarchy] => 1
>>>                                         [total_entries] => 35
>>>                                     )
>>>
>>>                                 [1] => Array
>>>                                     (
>>>                                         [section_id] => 40
>>>                                         [section_parent_id] => 38
>>>                                         [section_pos] => 33
>>>                                         [section_name] => Resource Center
>>>                                         [has_order] => 1
>>>                                         [section_has_hierarchy] => 1
>>>                                         [total_entries] => 35
>>>                                     )
>>>                             )
>>>
>>>
>>>
>>>
>>> [19] => Array
>>>     (
>>>         [section_id] => 26
>>>         [section_parent_id] => 0
>>>         [section_pos] => 45
>>>         [section_name] => Resource Center
>>>         [has_order] => 1
>>>         [section_has_hierarchy] => 1
>>>         [total_entries] => 55
>>>         [children] => Array
>>>             (
>>>                 [0] => Array
>>>                     (
>>>                         [section_id] => 27
>>>                         [section_parent_id] => 26
>>>                         [section_pos] => 46
>>>                         [section_name] => Newsletters Intro
>>>                         [has_order] => 0
>>>                         [section_has_hierarchy] => 1
>>>                         [total_entries] => 1
>>>                     )
>>>
>>>             )
>>>
>>>     )
>>>
>>
>>
>> maybe something like this
>>
>> in the foreach
>> if parent = 0 then level = 0;
>> if haschilden is true increment level;
>>
>>

How is the menu being displayed?  In a browser like jquery's plugin superfish?

--- End Message ---
--- Begin Message ---
Thanks for all your help. The answer was so simple in the end. Thanks Tim
for clearing that up!!! Perfect little script now for creating navigation.
Just feed it an array like posted at the bottom of this message.

function createTree(&$list, $parent){

    global $depth;

    $depth++; // Increment as we descend

    $tree = array();
//$depth = 0;
    foreach ($parent as $k=>$l){
$l['depth'] = $depth;
        if(isset($list[$l['section_id']])){
            $l['children'] = createTree($list, $list[$l['section_id']]);
        }
        $tree[] = $l;
    }

    $depth--; // Decrement as we ascend

    return $tree;
}

$arr = $dashSections;

$new = array();
foreach ($arr as $a){
    $new[$a['section_parent_id']][] = $a;
}

// CREATE THE TREE
$depth = 0;

$tree = createTree($new, $new[0]);
//echo count($tree);
print_r($tree);




On Thu, Aug 16, 2012 at 12:05 PM, Tristan <sunnrun...@gmail.com> wrote:

> Thanks David, Here's my tree creation. I'm trying to either put depth
> count on each array or run through the tree and figure it out after. I just
> can't figure out where to put it :D
>
> Great very lightweight script to create a tree from parent id and id if
> you want to save this one for yourself btw.
>
> function createTree(&$list, $parent){
>     $tree = array();
> //$depth = 0;
>     foreach ($parent as $k=>$l){
>  //echo $k.'<br />';
>         if(isset($list[$l['section_id']])){
> //echo $k.'<br />';
>  $l['depth'] = $k;
>             $l['children'] = createTree($list, $list[$l['section_id']]);
>         } else {
>  $l['depth'] = 0;
> }
>         $tree[] = $l;
>     }
>     return $tree;
> }
>
> $arr = $dashSections;
>
> $new = array();
> foreach ($arr as $a){
>     $new[$a['section_parent_id']][] = $a;
> }
>
> // CREATE THE TREE
> $tree = createTree($new, $new[0]);
> //echo count($tree);
> //print_r($tree);
>
>
>
> On Thu, Aug 16, 2012 at 11:36 AM, David OBrien <dgobr...@gmail.com> wrote:
>
>> On Thu, Aug 16, 2012 at 12:40 PM, Tristan <sunnrun...@gmail.com> wrote:
>>
>>> I can't for the life of me figure out how to find the depth of the array
>>> that I'm looping through to output tabs or indentations to the display
>>> for
>>> each depth. The entries also have section postition if you can figure out
>>> how to include that within each depth of the results I will buy you a
>>> case
>>> of beer.
>>>
>>> I was hoping to do something like...
>>>
>>> foreach($trees as $tree){
>>>     if($tree['current_depth'] == 0){
>>> echo $tree['menu_item'];
>>>     } else if($tree['current_depth'] == 1){
>>> echo 'indentation'.$tree['menu_item'];
>>>     } else if($tree['current_depth'] == 2){
>>> echo 'indentation - indentation'.$tree['menu_item'];
>>>     }
>>> }
>>>
>>>
>>> Or maybe even like this...
>>>
>>> foreach($trees as $tree){
>>> // output &nbsp; the amount of times current_depth equals
>>> echo str_repeat("&nbsp;", $tree['current_depth'])
>>> }
>>>
>>> I have my $tree structure as:
>>>
>>> [16] => Array
>>>     (
>>>         [section_id] => 21
>>>         [section_parent_id] => 0
>>>         [section_pos] => 30
>>>         [section_name] => Resource Center
>>>         [has_order] => 1
>>>         [section_has_hierarchy] => 1
>>>         [total_entries] => 35
>>>         [children] => Array
>>>             (
>>>                 [0] => Array
>>>                     (
>>>                         [section_id] => 38
>>>                         [section_parent_id] => 21
>>>                         [section_pos] => 31
>>>                         [section_name] => Resource Center
>>>                         [has_order] => 1
>>>                         [section_has_hierarchy] => 1
>>>                         [total_entries] => 35
>>>                         [children] => Array
>>>
>>>                             (
>>>                                 [0] => Array
>>>                                     (
>>>                                         [section_id] => 39
>>>                                         [section_parent_id] => 38
>>>                                         [section_pos] => 32
>>>                                         [section_name] => Resource Center
>>>                                         [has_order] => 1
>>>                                         [section_has_hierarchy] => 1
>>>                                         [total_entries] => 35
>>>                                     )
>>>
>>>                                 [1] => Array
>>>                                     (
>>>                                         [section_id] => 40
>>>                                         [section_parent_id] => 38
>>>                                         [section_pos] => 33
>>>                                         [section_name] => Resource Center
>>>                                         [has_order] => 1
>>>                                         [section_has_hierarchy] => 1
>>>                                         [total_entries] => 35
>>>                                     )
>>>                             )
>>>
>>>
>>>
>>>
>>> [19] => Array
>>>     (
>>>         [section_id] => 26
>>>         [section_parent_id] => 0
>>>         [section_pos] => 45
>>>         [section_name] => Resource Center
>>>         [has_order] => 1
>>>         [section_has_hierarchy] => 1
>>>         [total_entries] => 55
>>>         [children] => Array
>>>             (
>>>                 [0] => Array
>>>                     (
>>>                         [section_id] => 27
>>>                         [section_parent_id] => 26
>>>                         [section_pos] => 46
>>>                         [section_name] => Newsletters Intro
>>>                         [has_order] => 0
>>>                         [section_has_hierarchy] => 1
>>>                         [total_entries] => 1
>>>                     )
>>>
>>>             )
>>>
>>>     )
>>>
>>
>>
>> maybe something like this
>>
>> in the foreach
>> if parent = 0 then level = 0;
>> if haschilden is true increment level;
>>
>>
>

--- End Message ---

Reply via email to