Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6947601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:42:50+00:00 2026-05-27T13:42:50+00:00

I have an old custom built content management system in PHP, where users can

  • 0

I have an old custom built content management system in PHP, where users can write articles.

When the body text is displayed, I do a bunch of str_replace and ereg_replace calls to parse links and headings and other bits.

Now, there is a need to be able to enter a block of HTML code within the body text (occasionally) and have it not-parsed by the before-mentioned functions. These blocks should actually be rendered as HTML.

The block could be surrounded in a tag (i.e. [html] etc) to identify it but how do I exclude parsing of this section when I’m basically just running the before-mentioned functions over the entire body text block?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:42:50+00:00Added an answer on May 27, 2026 at 1:42 pm

    Obviously you need to parse something that does not include the area you want to leave as-is. So here’s one way you might do that:

    For each [html] block, generate a unique identifier (e.g. through uniqid or hashing something, possibly the contents of the block). Check that this identifier (which should be something that does not get affected by your other parsing, so alphanum would be a good choice) does not actually exist in the text. If it does, generate another.

    Save the identifier and the contents of the corresponding [html] block in an array using the identifier as a key. Then replace the substring [html]blah[/html] with [html]identifier[/html] in your input.

    Proceed with parsing as normal, and when you are done replace back the [html]identifier[/html] bits with the real content. You can do this with just one call to preg_replace for all blocks if you take advantage of the /e (evaluate replacement string as code) option.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have created custom listview by using the Base adapter. List view contains Text
We have a custom php email marketing app, and an interesting problem: If the
We have built custom forms and at this stage are built very well with
This should be simple but I can't find a solution: I have a custom
I have a MVC site which I have built a custom authentication for. I
I have old code that uses size_t which IIRC comes from cstring.h. On OS
Most of the software company have old software which continue maintain, and they also
I have an old .dot file with a few dozen styles in it. I
I have a old website that generate its own RSS everytime a new post
I have several old 3.5in floppy disks that I would like to backup. My

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.