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 7530073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:48:41+00:00 2026-05-30T04:48:41+00:00

Good day all, I have a preset situation that can’t be changed, that revolves

  • 0

Good day all,

I have a preset situation that can’t be changed, that revolves around a portion of html text (the body of a page), and some user configurable tags inside this body.

The problem, which is very template-like but that’s related to a non-refactorable source situation, is that I need to split the original body into

html part 1
tag1
html part 2
tag2
html part 3
tag3

and so on, taken for example from

<body>
<b>This is my first line</b> And this is <b>%%tag one%%</b> but of course it
doesn't end here %%second tag%%
Additionally %%second tag%% tags can be repeated inside the body.

In fact, %%tag one%% or even %%tagthree%%
</body>

Ideally, I should obtain an array:

[0] = "<body>
    <b>This is my first line</b> And this is <b>"
[1] = "%%tag one%%"
[2] = "</b> but of course it
    doesn't end here "
[3] = "%%second tag%%"
[4] = "Additionally "
[5] = "%%second tag%%"
[6] = " tags can be repeated inside the body.

    In fact, "
[7] = "%%tag one%%"
[8] = " or even "
[9] = "%%tagthree%%"
[10] = "
    </body>"

Tags are simple text labels (allow space, _ and -) enclosed by %%, for example %%first tag%%

I realize there’s a lot of different solutions, but since I have a need for the highest possible performance, I am in need of directions for what to try and what to avoid. Additionally, I’m wondering if php already has some function for this kind of case.

Hopefully some of you have already faced something like this, which is a bit too much to solve ideally, for my current parsing skills.

Thanks

  • 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-30T04:48:42+00:00Added an answer on May 30, 2026 at 4:48 am

    A dumb way:

    $parts = explode("%%", $str);
    for($i=1;$i<count($parts);$i+=2) {
        $parts[$i] = "%%".$parts[$i]."%%"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good day all; I have an UIImageView that I animate around a large UIView.
Good day to all. I have this setup: One page with text/whatever, that also
Good day all, I have written an application that i require to have a
Good day to all. I have this structure <html> <iframe> <div id=idd>Some Content</div> </iframe>
Good Day all, I have an existing site built. I was wondering, how can
Good day to all. I have the following setup: A page with html, js,
Good day to all. I have a little problem. Can anyone tell me or
Good day to all. I have a movie that need 2 be displayed with
Good day all I have the following question: I would like to use Chart
Good day, I have a local csv file with values that change daily called

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.