I know I can use a php array but that wasn't the question!!! And no it
wouldn't be simpler, certainly for my purpose. The tree structure I need to
build is much bigger and much more complex than the example I gave below, so
using a normal array is simply not an option. Besides, the tree structure
needs to be independent of any programming language.

"Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message
news:3DCA5D5E.7090707@;webglobe.sk...
> Why cannot you store it in the file as array and just include it.
> Simpler and much faster
>
>
> Rishabh Gupta wrote:
>
> >Hi all,
> >    I want to write a parser that would read a menu structure in a text
> >file, parse it and then turn that into an array structure. The menu
> >structure would use brackets to represent a new submenu and for each item
in
> >the menu there would be some extra properties. EG:
> >
> >Root
> >(
> >    Sub1
> >    (
> >        Sub1A
> >        Sub1B
> >    )
> >    Sub2
> >    (
> >        Sub2A
> >        (
> >            Sub2Aa
> >            Sub2Ab
> >        )
> >        Sub2B
> >    )
> >)
> >
> >
> >The parser needs to turn that menu structure into something like this:
> >
> >"Root" => array
> >(
> >    "Sub1" => array
> >    (
> >        "Sub1A",
> >        "Sub1B",
> >    ),
> >    "Sub2" => array
> >    (
> >        "Sub2A" => array
> >        (
> >            "Sub2Aa",
> >            "Sub2Ab"
> >        ),
> >        "Sub2B"
> >    )
> >)
> >
> >
> >In addition to this, I need to have the additional feature of storing
> >addition information for each item in the menu. Thus
> >
> >Root
> >(
> >    Sub1                                        name=sub1    title="the
> >title 1"
> >    (
> >        Sub1A
> >        Sub1B
> >    )
> >    Sub2
> >)
> >
> >Would Become Something Like
> >
> >"Root" => array
> >(
> >    "Sub1" => array
> >    (
> >        "info" => array("name"=>sub1, "title"=>"the title 1"),
> >        "" => array
> >        (
> >            "Sub1A",
> >            "Sub1B",
> >        )
> >    ),
> >    "Sub2" => array
> >)
> >
> >
> >Could somebody recommend to what is the best way to implement such a
> >function. There are essentially two parts to this. The first part reads
and
> >parses the text file, and the second part puts the structure into an
array.
> >Any help would be greatly appreciated.
> >
> >Many Thanks
> >
> >Rishabh
> >
> >
> >
> >
> >
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to