fetchObject($db->select('text')->from('table.contents') ->where('slug = ?', $slug)->limit(1)); if (!$contents) { return; } $text = $contents->text; $cats = preg_split("/<\/(ol|ul)>/i", $text); foreach ($cats as $cat) { $item = trim($cat); if ($item) { $matches = array_map('trim', preg_split("/<(ol|ul)[^>]*>/i", $item)); if (2 == count($matches)) { list ($title, $list) = $matches; echo "<$tag>" . strip_tags($title) . ""; echo "<$listTag>" . $list . ""; } } } } }