Welcome Guest, Not a member yet? Register   Sign In
Creating a view from an unlimited child/parent array
#2

[eluser]wh1tel1te[/eluser]
Hi Paul,

Easiest way to do this in my opinion would be to create another recursive function to display the list. Here's my go at it:

Code:
<?php
function listroles($roles)
{
    ?>
    <ul>
    &lt;?php
    foreach($roles as $role)
    {
        ?&gt;
        <li>
            <p>&lt;?php echo $role['role_name']; ?&gt;</p>
            &lt;?php
            if ( ! empty($role['children']))
            {
                listroles($role['children']);
            }
            ?&gt;
        </li>
        &lt;?php
    }
    ?&gt;
    </ul>
    &lt;?php
}
?&gt;

Try passing your array into this function and see what comes out. Note, this code is untested!


Messages In This Thread
Creating a view from an unlimited child/parent array - by El Forum - 03-16-2011, 04:28 PM
Creating a view from an unlimited child/parent array - by El Forum - 03-16-2011, 04:47 PM
Creating a view from an unlimited child/parent array - by El Forum - 03-16-2011, 05:04 PM



Theme © iAndrew 2016 - Forum software by © MyBB