Stringmethoden
bjoern
- php
0 Ashura
Hallo Leute,
ich möchte in einem String <font color='#359228'>%2B</font> in ein "+"umwandeln.
Der Gesamte String lautet "news= Blabla1 <font color='#359228'>%2B</font><font color='#359228'>%2B</font><font color='#359228'>%2B</font> Blabla2 <font color='#359228'>%2B</font><font color='#359228'>%2B</font><font color='#359228'>%2B</font>".
Hierzu benutze ich "str_replace("<font color='#359228'>%2B</font>","+",$ticker);", was aber nicht funktioniert. Schätze liegt daran, dass die <font color='#359228'>%2B</font> Elemente ohne Leerzeichen direkt hintereinander folgen. Wie kann ich diese trotzdem umwandeln (möchte nicht alle drei + in einem str_replace() abarbeiten, weil es auch mal sein kann dass im String nur 1 oder 2 + hintereinander vorkommen.) Außerdem suche ich eine elegante Lösung den Stringanfang "news=" zu entfernen.
Wer kann helfen?
Dankeschön
bjoern
Hallo bjoern.
Hierzu benutze ich "str_replace("<font color='#359228'>%2B</font>","+",$ticker);", was aber nicht funktioniert.
Funzt doch einwandfrei?
<?php
$ticker = "news= Blabla1 <font color='#359228'>%2B</font><font color='#359228'>%2B</font><font color='#359228'>%2B</font> Blabla2 <font color='#359228'>%2B</font><font color='#359228'>%2B</font><font color='#359228'>%2B</font>";
$ticker = str_replace("<font color='#359228'>%2B</font>","+",$ticker);
echo $ticker;
?>
Einen schönen Donnerstag noch.
Gruß, Ashura