Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Jak zamienić link na tekst?
Saki
post
Post #1





Grupa: Zarejestrowani
Postów: 240
Pomógł: 2
Dołączył: 5.12.2010
Skąd: Fulda

Ostrzeżenie: (0%)
-----


Witam, mam mały problem, muszę zamienić:
z:
Lorem ipsum dolor sit amet, <a href="http://google.com/" target="_blank">[LINK]</a> consectetur adipiscing elit.
na:
"Lorem ipsum dolor sit amet, http://google.com/ consectetur adipiscing elit."

Próbowałem:
  1. $dane[6][$i] = preg_replace("#<a href=\"#", "", $dane[6][$i]);
  2. $dane[6][$i] = preg_replace("#\" target=\"_blank\">[LINK]</a>#", "", $dane[6][$i]);
  3. $dane[6][$i] = preg_replace("#target=\"_blank\">[LINK]</a>#", "", $dane[6][$i]);


Ale usuwa tylko <a href=" a końcówka " target="_blank">[LINK]</a> zostaje.
Czy wiecie jak to naprawić, lub macie lepszy pomysł na zamianę?

Ten post edytował Saki 7.06.2012, 19:38:30
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
k_@_m_i_l
post
Post #2





Grupa: Zarejestrowani
Postów: 349
Pomógł: 72
Dołączył: 22.01.2008
Skąd: Wadowice/Oświęcim

Ostrzeżenie: (0%)
-----


  1.  
  2. $link = '<a target="_blank" href="http://google.com/" >abc</a>';
  3. $test = preg_replace('#<a(.*)href="(.*)"(.*)>(.*)<\/a>#is','<a href="$2">$2</a>',$link);


Spróbuj coś takiego.

Ten post edytował k_@_m_i_l 7.06.2012, 20:36:06
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 6.10.2025 - 10:57