Huhu dbenzhuser
Momentan sieht das Ding so aus:
$bla = preg_replace("!{{(.*)}}!U", $_POST[$1], $string);
Eine einfache Möglichkeit wäre der e-modifier (eval).
Also z.B. so
<?php
$test = array ('LAND' => 'Griechland', 'STADT' => Athen);
$text = "Die Haupstadt von {LAND} ist {STADT}.";
$bla = preg_replace('#{(.*)}#Ue', '$test["$1"]', $text);
echo $bla;
?>
Oder als Funktion
<?php
$test = array ('LAND' => 'Griechland', 'STADT' => Athen);
$text = "Die Haupstadt von {LAND} ist {STADT}. {FAHNE}";
function ReplacePlaceHolder($v, $arr)
{
$v = preg_replace ('/({(.*)})/eU', "isset($arr['\2'])?$arr['\2']:'\1'",$v);
return $v;
}
echo ReplacePlaceHolder($text, $test);
?>
Viele Grüße
lulu
--
bythewaythewebsuxgoofflineandenjoytheday
bythewaythewebsuxgoofflineandenjoytheday