I have several unordered lists. The list items are URLs. How can I extract the URL and link text from each list item to insert into a database?
<ul id="1">
<li><a href="someplace.com">Text</a></li>
<li><a href="someplace.com">Text</a></li>
<li><a href="someplace.com">Text</a></li>
</ul>
<ul id="2">
<li><a href="someplace.com">Text</a></li>
<li><a href="someplace.com">Text</a></li>
<li><a href="someplace.com">Text</a></li>
</ul>
<ul id="3">
<li><a href="someplace.com">Text</a></li>
<li><a href="someplace.com">Text</a></li>
<li><a href="someplace.com">Text</a></li>
</ul>
I know RegEx should be avoided. I already have the PDO set up. The ul id number goes into the categoryID on the mysql table.
The only thing that seems to make sense would be something like a while-loop with another loop inside to get the URLs and text, and then after increment the id. I just don't know how to start it. Should the URL and text go into an array?
DOMDocumentor another PHP DOM library.