hallo,
ich versuche mittels match und replace bilder die in einem -TAG sind zu finden und zu ersetzen.
Beispiel:
$content = 'Das hier ist ein Contenteintrag
[IMG]small_Bildschirmfoto 2012-08-26 um 14.08.20.png[/IMG]
[IMG]small_Bildschirmfoto 2012-08-27 um 21.36.00.png[/IMG]
[IMG]small_Bildschirmfoto 2012-08-27 um 22.12.00.png[/IMG]';[/PHP]
Der Aufruf wäre dann:
[PHP] if(preg_match_all("/\[IMG\](.*)\[\/IMG\]/", $text, $hits) > 0) {
foreach( $hits as $i => $k ) {
$fullmatch = $hits[0][$i];
$filename = $hits[1][$i];
$text = str_replace($fullmatch, $this->media->checkFileExist($filename), $text);
}
}
über media wird geprüft ob das Bild existiert und dann entsprechend als html-tag zurück gegeben.
mein problem ist nun, das ich die ersten 2 bilder umgewandelt bekomme, bild 3 wird nicht umgewandelt.
var_dump sieht ok aus:
array(2) {
[0]=>
array(3) {
[0]=>
string(58) "[IMG]small_Bildschirmfoto 2012-08-26 um 14.08.20.png[/IMG]"
[1]=>
string(58) "[IMG]small_Bildschirmfoto 2012-08-27 um 21.36.00.png[/IMG]"
[2]=>
string(58) "[IMG]small_Bildschirmfoto 2012-08-27 um 22.12.00.png[/IMG]"
}
[1]=>
array(3) {
[0]=>
string(47) "small_Bildschirmfoto 2012-08-26 um 14.08.20.png"
[1]=>
string(47) "small_Bildschirmfoto 2012-08-27 um 21.36.00.png"
[2]=>
string(47) "small_Bildschirmfoto 2012-08-27 um 22.12.00.png"
}
}[/PHP]
hat jemand eine Idee?