Gordon Werner Posted September 15, 2009 Share Posted September 15, 2009 I have a bunch of code that requires users to enter text. To avoid certain problems, I restrict the tags they can use to mark up the text ... using bracket tags instead of html tags like [b]...[/b] which I then replace at runtime using eregi_replace. this is not a problem for things like bold text ... $description = eregi_replace('\[b]([^]]*)\[/b]', '<b>\1</b>', $description); but how do I handle things like bullet lists where I want to let the user only have to enter [*] ? right now, all I do is this: $description = eregi_replace('\[\*]', '<li>', $description); but this makes the XHTML validation fail (no closing </li> tags) ... is there an easy way that I can have the code auto-insert the </li> tag? and how would the above code snippet have to change? Thanks G. Quote Link to comment https://forums.phpfreaks.com/topic/174379-eregi_replace-question/ Share on other sites More sharing options...
.josh Posted September 15, 2009 Share Posted September 15, 2009 The easiest thing to do would be to make the user mark it up like any other tag: [*]something that is how most forums do it. p.s. - stop using posix functions (ereg**) they are deprecated and are removed from the php core as of v6. Use the pcre functions (preg**) instead. Quote Link to comment https://forums.phpfreaks.com/topic/174379-eregi_replace-question/#findComment-919231 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.