Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/174379-eregi_replace-question/
Share on other sites

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.

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.