Hallo,
ich habe ein Problem. Ich möchte aus einer Variable mit preg_match teile auslesen. Die Variable hat folgenden Inhalt:
Code:
"Startseite<br/>{if BLAAA==BLUUB}Halli Hallo{/if}<br/>Test Test Test"
Wie kann ich da folgenden Code auslesen?:
{if BLAAA==BLUUB}Halli Hallo{/if}
Ich habe es anfangs so gemacht das ich nur {if BLAAA==BLUUB} auslese, jedoch brauche ich den gesamten Block. Das habe ich so gemacht:
PHP-Code:
$pattern = sprintf("/\\%s[\s]*(%s)([^\\%s]*)\\%s/i", '{', 'if', '}', '}');
preg_match_all($pattern, $this->template, $this->conditions);
Jetzt habe ich es so probiert:
PHP-Code:
$pattern = sprintf('/{if \/\/[a-z0-9A-Z.]}+(?(?=[\/])(.*))+{/if}/');
preg_match_all($pattern, $this->template, $this->conditions);
Jedoch klappt das nicht so ganz. Kann mir dabei evtl. jemand helfen?
Danke schon mal im voraus.
Gruß,
TorrnexT