Display discription list with foreach loop in PHP

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>

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().

Sponsor our Newsletter | Privacy Policy | Terms of Service