Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I extract structured text from an HTML list in PHP?
    primarykey
    data
    text
    <p>I have this string:</p> <pre><code>&lt;ul&gt; &lt;li id="1"&gt;Page 1&lt;/li&gt; &lt;li id="2"&gt;Page 2 &lt;ul&gt; &lt;li id="3"&gt;Sub Page A&lt;/li&gt; &lt;li id="4"&gt;Sub Page B&lt;/li&gt; &lt;li id="5"&gt;Sub Page C &lt;ul&gt; &lt;li id="6"&gt;Sub Sub Page I&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li id="7"&gt;Page 3 &lt;ul&gt; &lt;li id="8"&gt;Sub Page D&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li id="9"&gt;Page 4&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>and I want to explode every information with PHP and make it like:</p> <pre><code>---------------------------------- | ID | ORDER | PARENT | CHILDREN | ---------------------------------- | 1 | 1 | 0 | 0 | | 2 | 2 | 0 | 3,4,5 | | 3 | 1 | 2 | 0 | | 4 | 2 | 2 | 0 | | 5 | 3 | 2 | 6 | | 6 | 1 | 5 | 0 | | 7 | 3 | 0 | 8 | | 8 | 1 | 7 | 0 | | 9 | 4 | 0 | 0 | ---------------------------------- </code></pre> <p>For extra information, this is what this list means for me:</p> <p>ID 1 is 1st (Page 1) and has 0 parents and 0 children,</p> <p>ID 2 is 2nd (Page 2) and has 0 parents and children IDs 3,4,5,</p> <p>ID 3 is 1st (Sub Page A) and has parent ID 2 and 0 children,</p> <p>ID 4 is 2nd (Sub Page B) and has parent ID 2 and 0 children,</p> <p>ID 5 is 3rd (Sub Page C) and has parent ID 2 and children ID 6,</p> <p>ID 6 is 1st (Sub Page I) and has parent ID 5 and 0 children,</p> <p>ID 7 is 3th (Page 3) and has 0 parents and children ID 8,</p> <p>ID 8 is 1st (Sub Page I) and has parent ID 7 and 0 children,</p> <p>ID 9 is 4th (Page 4) and has 0 parents and 0 children.</p> <p>If this is too tough, can anyone sugest how to get that info from this string with another method?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload