Display discription list with foreach loop in PHP

#1

I have a file with information in the follwing format:
Category: item, item, item…
I have a preg_split to deal with the file, seperating info by “:” and “\n”
It works when I just place the info as

<dt>line[0]</dt>
<dd>line[1]</dd>

and that displayed everything fine. But I need to do something like this:

  foreach ($lines as $line) {
    echo"<dt>$line</dt>";
  }

How would I get this to display in the correct format?, i.e.

    <dt>Category1</dt>
    <dd> item, item, item...</dd>
    <dt>Category2</dt>
    <dd> item, item, item...</dd>
    <dt>Category3</dt>
    <dd> item, item, item...</dd>
#2

If you split it up correctly your $line should have two entries, one with category and on with items. You can see this with var_dump().