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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:41:05+00:00 2026-06-15T14:41:05+00:00

I’m working on a tool to replace tagged areas in a html document. I’ve

  • 0

I’m working on a tool to replace tagged areas in a html document. I’ve had a look at a few php template systems, but they are not really what I am looking for, so here is what I am after as the “engine” of the system. The template itself has no php and I’m searching the file for the keyword ‘editable’ to set the areas that are updatable. I don’t want to use a database to store anything, instead read everything from the html file itself.

It still has a few areas to fix, but most importantly, I need the part where it iterates over the array of ‘editable’ regions and updates the template file.

Here is test.html (template file for testing purposes):

<html>

<font class="editable">
This is editable section 1
</font>
<br><br><hr><br>
<font class="editable">
This is editable section 2
</font>

</html>

I’d like to be able the update the ‘editable’ sections via a set of form textareas. This still needs a bit of work, but here is as far as I’ve got:

<?php

function g($string,$start,$end){ 
     preg_match_all('/' . preg_quote($start, '/') . '(.*?)'. preg_quote($end, '/').'/i', $string, $m); 
     $out = array(); 

     foreach($m[1] as $key => $value){ 
       $type = explode('::',$value); 
       if(sizeof($type)>1){ 
          if(!is_array($out[$type[0]])) 
             $out[$type[0]] = array(); 
          $out[$type[0]][] = $type[1]; 
       } else { 
          $out[] = $value; 
       } 
     } 
  return $out; 
}; 

// GET FILES IN DIR
   $directory="Templates/";
   // create a handler to the directory
    $dirhandler = opendir($directory);
    // read all the files from directory
    $i=0;
    while ($file = readdir($dirhandler)) {
        // if $file isn't this directory or its parent 
        //add to the $files array
        if ($file != '.' && $file != '..')
        {
                $files[$i]=$file; 
          //echo $files[$i]."<br>";
          $i++;                
        }   
    };
//echo $files[0];

?>

<div style="float:left; width:300px; height:100%; background-color:#252525; color:#cccccc;">
<form method="post" id="Form">
Choose a template:
<select>
<?php
// Dropdown of files in directory
foreach ($files as $file) {
  echo "<option>".$file."</option>"; // do somemething to make this $file on selection. Refresh page and populate fields below with the editable areas of the $file html
};
?>
</select>
<br> 
<hr>
Update these editable areas:<br>

<?php


$file = 'test.html';  // make this fed from form dropdown (list of files in $folder directory)
$html = file_get_contents($file);

$start = 'class="editable">';
$end = '<';

$oldText = g($html,$start,$end);

$i = 0;
foreach($oldText as $value){
  echo '<textarea value="" style="width: 60px; height:20px;">'.$oldText[$i].'</textarea>';  // create a <textarea> that will update the editable area with changes
  // something here
  $i++;
};

// On submit, update all $oldText values in test.html with new values.
?>
<br><hr>
&nbsp;<input type="submit" name="save" value="Save"/>  
</div>
<div style="float:left; width:300px;">
<?php include $file; // preview the file from dropdown. The editable areas should update when <textareas> are updated ?>
</div>
<div style="clear:both;"></div>

I know this answer is a little more involved, but I’d really appreciate any help.

  • 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-06-15T14:41:07+00:00Added an answer on June 15, 2026 at 2:41 pm

    Not sure if i correctly understand what you want to achieve. But it seems I would do that in jquery.

    You can get all html elements that has the “editable” class like this :

    $(".editable")
    

    You can iterate on them with :

    $(".editable").each(function(index){
        alert($(this).text()); // or .html()
        // etc... do your stuff
    });
    

    If you have all your data in a php array. You just need to pass it to the client using json. Use php print inside a javascript tag.

    <?php
    
    print "var phparray = " . json_encode($myphparray);
    
    ?>
    

    I think it would be better to put the work on the client side (javascript). It will lower the server work load (PHP).

    But as I said, I don’t think I’ve grasped everything you wanted to achive.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want to count how many characters a certain string has in PHP, but
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.