There are a large numbers of PHP variables I use in my template files and some of them need to be accessible for editors who can only use HTML. What I want to do exactly is have them identify the variable doing something like [ITEM_NAME_1] when typing/editing content, and PHP finds them because they are wrapped in brackets, and replaces them with the appropriate PHP variable (in that case, $ITEM_NAME_1)
The content of each page is in a variable "$page_content", so right now the only way I know how to accomplish is to manually write lines to replace what I need.
$page_content = str_replace("[ITEM_NAME_1]", "$ITEM_NAME_1", "$page_content");
print $page_content
The issue is there are hundreds of these "ITEM_NAME_X" variables and I don't want to have to create a massive repeat of "str_replace" lines manually for each ITEM_NAME_X.
What I want to accomplish is have PHP find anything inside $page_content that is wrapped in brackets [], take the name from inside the bracket and replace all of it with the variable of that bracketted name. So if it finds [ITEM_5], it replaces it with $ITEM_5. Is this at all possible? Let me know, thanks.