Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] wyciąganie tytuły ze stringa, mój odwiedzny problem :(
matix
post
Post #1





Grupa: Zarejestrowani
Postów: 278
Pomógł: 10
Dołączył: 13.02.2007
Skąd: Rybnik

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


Witam serdecznie.

Czy ktoś mogłby mi pomóc wyciągnąc tytuł ze stringa:

  1. <a href="http://matix.org/" class=l><b>Matix</b>.Org - tworzenie stron internetowych</a>


Musiałbym mieć coś takiego:

  1. http://matix.org - <b>Matix</b>.Org - tworzenie stron internetowych


Chcialbym to wyciągnąc za pomocą preg_match_all, ale próbuję juz chyba godzinę i nic (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)

Może mi ktoś pomóć? Dzieki (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
sheerun
post
Post #2





Grupa: Zarejestrowani
Postów: 15
Pomógł: 0
Dołączył: 20.05.2007

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


Trochę namieszałeś barat...

  1. <?php
  2. $pattern = '@<a href="([^"]+)".*>(.*)</a>@imU';
  3. $str = '<a href="http://matix.org/" class=l><b>Matix</b>.Org - tworzenie stron internetowych</a><a href="http://unny.org/" class=l><b><i>Inny</i></b> link do innej strony</a>';
  4. preg_match_all($pattern, $str, $res, PREG_SET_ORDER);
  5. foreach($res as $r) {
  6. echo "{$r[1]} - {$r[2]}<br />";
  7. }
  8. ?>
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: 8.10.2025 - 00:38