PHP-Code:
<?
$part = " ...
<test:tpl name=\"navi_repeat\" key=\"1\">"
." {kategorie}<br /></test:tpl name=\"navi_repeat\">
...";
echo "Original:\n".$part."\n------\n";
$array = Array("1<br />","2<br />","3<br />");
if(preg_match("/(\s*)<(test:tpl name=\"navi_repeat\") key=\"1\">(.*?)<\/\\2>/is",$part))
{
echo "Value:\n".implode(null,$array)."\n\n------\n";
$preg1 = "/(\s)<(test:tpl name=\"navi_repeat\") key=\"1\">(.*?)<\/\\2>/is";
$part2 = preg_replace($preg1,implode("$1",$array),$part);
echo "Ergebnis1:\n".$part2."\n\n------\n\n";
$preg2 = "/\n?(\s*)<(test:tpl name=\"navi_repeat\") key=\"1\">(.*?)<\/\\2>/is";
preg_match($preg2,$part,$whitespaces);
$whitespaces = "\n".$whitespaces[1];
echo "Whitespaces:\n".$whitespaces."\n\n------\n\n";
$value = implode($whitespaces,$array);
$preg3 = "/<(test:tpl name=\"navi_repeat\") key=\"1\">(.*?)<\/\\1>/is";
$part3 = preg_replace($preg3,$value,$part);
echo "Ergebnis2:\n".$part3;
}
?>
Ergebnis:
Code:
Original: ... <test:tpl name="navi_repeat" key="1"> {kategorie}<br /></test:tpl name="navi_repeat"> ... (hab ich wegen dem forum vor der {kategorie} umgebrochen ------ Value: 1<br />2<br />3<br /> ------ Ergebnis1: ... 1<br /><br /><br /> ... ------ Whitespaces: ------ Ergebnis2: ... 1<br /> 2<br /> 3<br /> ...
Kommentar