Jump to content

Multi Dimensional array from string.


Chris92

Recommended Posts

I'm trying to explode a string into a logical array that will be built into a multi dimensional navigation.

 

basically the array would need to look like this:

 

Array
(
    [Home] => home.php
    [services] => Array
        (
            [0] => services.php
            [Foo] => Array
                (
                    [0] => foo.php
                    [bar] => chocolate.php
                )

        )

    [Contact] => contact.php
)

 

And it will turn into a ul list:

 

<ul>
    <li> <a href="home.php">Home</a> </li>
    <li>
        <a href="services.php">Services</a>
        <ul>
            <li>
                <a href="foo.php">Foo</a>
                <ul>
                    <li> <a href="chocolate.php">Bar</a> </li>
                </ul>
            </li>
        </ul>
    </li>
    <li> <a href="contact.php">Contact</a> </li>
</ul>

 

I would just like to know if it would be possible to make an array like this from a string.

Link to comment
https://forums.phpfreaks.com/topic/197802-multi-dimensional-array-from-string/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.