You are not logged in.

wcf.regNote.message

Opi62

Trainee

  • "Opi62" started this thread

Posts: 91

Location: 127.0.0.1

  • Send private message

1

Monday, October 12th 2009, 4:17am

BB_Coder [url=] Problehm

hi ich habe ein Kleines Problehm.

und zwar würde ich gern [.url=http://host.de]diese seite[./url] links so erstellen.
Nur leider Funktioniert das noch nicht So Ganz wie ich mir Das vorstelle.

So sieht mein Code bis jetzt aus.

[php]<?php
$text = str_replace("[url=", "<a href=\"", $text);
$text = str_replace("/]", "\" target=\"_blank\">", $text);
$text = str_replace("[/url]", "</a>", $text); ?>
[/php]

Wäre nett wenn ihr mir helfen könntet.

Gruß Opi62

Prometheus

Administrator

Posts: 3,278

  • Send private message

2

Monday, October 12th 2009, 7:58am

Moin,

ich würde sagen besser geht sowas mit preg_replace und richtigen regular expressions. Ist zwar etwas komplizierter aber dafür auch etwas besser von den Filtermöglichkeiten.

Wie die Funktion arbeitet kannst Du da nachlesen -> http://de2.php.net/manual/de/function.preg-replace.php
Jedwege Anfragen bitte an Technomausi oder ShaoKhan richten. Dieses Konto ist und bleibt inaktiv.

Opi62

Trainee

  • "Opi62" started this thread

Posts: 91

Location: 127.0.0.1

  • Send private message

3

Monday, October 12th 2009, 2:39pm

Danke ich werde es mir mal ansehn

Opi62

Trainee

  • "Opi62" started this thread

Posts: 91

Location: 127.0.0.1

  • Send private message

4

Wednesday, October 14th 2009, 3:08pm

Hier noch die Lösung meines Problehms

[PHP]
$text = preg_replace('#\[url=(.*)\](.*)\[/url\]#Uis', '[url='\1']\2[/url]', $text);
[/PHP]

Gruß

Opi62

Prometheus

Administrator

Posts: 3,278

  • Send private message

5

Wednesday, October 14th 2009, 3:54pm

Das ist doch prima dann hat das ja wirklich funktioniert.
Jedwege Anfragen bitte an Technomausi oder ShaoKhan richten. Dieses Konto ist und bleibt inaktiv.