I'm creating some sort of bbcode for one of the projects I'm working on, and am running into a bit of trouble with a [list] tag.
The list tag was supposed to look like this:
[list=#]
[*]ListItem
[/list]
Where # is the type of list.
This is what I started with:
Now, since I also run nl2br() on the $msg, it replaces newlines with <br /> tags. So my list ends up looking like this:Code:$tags = array("/\[list=1\](.*)\[\/list\]/siU", "/\[list=2\](.*)\[\/list\]/siU", "/\[list=3\](.*)\[\/list\]/siU", "/\[\*\](.*)/siU"); $html = array("<ol>\\1</ol>", "<ol type=\"a\">\\1</ol>", "<ul>\\1</ul>", "<li>\\1"); $msg = preg_replace($tags, $html, $msg);
The <br />'s in there create a lot of problems with spacing and margins.Code:<ol><br /> <li>Testing<br /> <li>The<br /> <li>Numbered<br /> <li>List</ol><br />
So my question is: how can I remove the newlines with my expression?




Reply With Quote