0

I want to create an Array like this:

"content" => [
    [
        "p" => true,
        "text" => "Some nasty text"
    ],
    [
        "ul" => [
            [ 
                "top" => true,
                "li" => true,
                "text" => "firstElement"
            ], 
            [
                "ul" => [
                    [
                        "li" => true,
                        "text" => "Nested Element"
                    ],[
                        "ul" => [
                            [
                                "li" => true,
                                "text" => "Nested Element2"
                            ]
                        ]
                    ]
                ]
            ],
                    [
                "li" => true,
                "text" => "elem"
            ], 
        ]
    ]

by parsing a HTML page. I got the HTML as a string from another method. Is there any tool or algorithm out there i can use for this ? Also i want to be able to add soem special attribute to the first "ul" for example.

After getting the HTML in this Array form i want to run it through mustache.

Frossy
  • 448
  • 7
  • 17
  • 1
    You would be best off using DOMDocument and loadHTML as it allows you to properly capture the hierarchy of the source. – Nigel Ren Feb 27 '19 at 16:59
  • Once you have some code which loads the HTML - if you have specific problems with it and generating your required output then please come back and we can help with that. – Nigel Ren Feb 27 '19 at 17:01

0 Answers0