I'm looking for a way to convert a HTML definition list <dl>
into a nested array with PHP.
Example list:
<dl>
<dt>A</dt>
<dd>A1</dd>
<dt>B</dt>
<dd>B1</dd>
<dd>B2</dd>
</dl>
Preferred output:
[ 'A' => ['A1'], 'B' => ['B1', 'B2'] ]
I already found a jQuery solution (Turning HTML <dl> into a nested JavaScript array with jQuery) which works (almost) like I want it to be BUT I'm working on a jQuery-less project and would therefor like to do the same with just PHP.
I've also already looked at PHP functions like XML_PARSE_INTO_STRUCT but unfortunately I don't get to a working solution with it.
So I'm currently stuck with my search. Can anyone give me a pointer into the right direction?
to
code already isolated. – golabs Jun 04 '18 at 21:05