I'm trying to make little function in php that processes if/then type statements within a string, removing any part of the string that doesn't match the condition. For example:
should return "ABCDEFGHI". If $x were not 2, then it should return "ABCGHI".
The "[if " is the start tag for the condition, and the condition should be valid php code (could even be a more complex evaluation).
I essentially need to swallow the tags, as well as any data between the [if] and [/if] if it isn't true.
Next, I really need this to be able to be recursive, just like in a programming language. For example:
$string="ABC[if $x==2]DEF[if $y>7]GHI[/if]JKL[/if]MNO";
Should print out "ABCDEFJKLMNO", because the first test is true, while the second is false.