I'm trying to build a program that can read variables from a template and allow the user to edit them. I'm trying to use regex to find instances of user-defined variables in the template, which would look like ##VARIABLENAME##
.
I essentially want to grab the VARIABLENAME
part into an array item, for each variable that exists in the source string.
I looked around a bit but couldn't find anything, regex syntax is quite a beast to someone who hasn't used it before.
Any help appreciated!
EDIT:
Sample input:
"Hello there ##NAME##, you have ##ORDERSNUM## orders pending".
Expected output:
array[0] = 'NAME'
array[1] = 'ORDERSNUM'
I've so far tried
preg_match("/#(.*)#/", $temphtml, $tempvars)
But this is only returning the first match found, twice.