I need some help figuring out the most optimal way to search and replace occurences of a string within an included file without actualy rewriting the file. The purpose is to do this without needing any php code in the included files. Here is the specific logic behind my case:
if (isset($iframes))
search all occurences of "[target]"
and replace with "target='someframe'"
include "file.html";
} else {
search all occurences of "[target]"
and replace with ""
include "file.html";
}
I suppose the logic is the same as what is used with BBcode but I cant figure out if it's best to read the file into an array, make the search and replace and output the results or if there is a better way.
Anyone?
Thanks