Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Preg_match
vegeta
post
Post #1





Grupa: Zarejestrowani
Postów: 122
Pomógł: 0
Dołączył: 9.11.2008

Ostrzeżenie: (10%)
X----


  1. preg_match_all("/<a(?:[^>]*)href=\"(http:\/\/[^\"]*)\"(?:[^>]*)>(?:[^<]*)<\/a>/is", $stripped_file, $matches);


Co mam zrobić, aby wypluwało mi tylko linki do stron głównych? Chodzi mi o to, aby nie wypluwało wyników, które mają kilka / po głównym adresie. Chcę, żeby wyświetlało mi tylko wyniki z jednym / i bez niego np. http://onet.pl i http://onet.pl/, ale nie dawało już http://onet.pl/dzieci_neo albo http://onet.pl/dzieci_neo/blaaa/
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
vegeta
post
Post #2





Grupa: Zarejestrowani
Postów: 122
Pomógł: 0
Dołączył: 9.11.2008

Ostrzeżenie: (10%)
X----


Kolejny problem. Chcę wyświetlić tablice:

  1. <?php
  2. $original_file = file_get_contents("http://it-maniak.pl/");
  3. $stripped_file = strip_tags($original_file, "<a>");
  4. preg_match_all('#href="(http://[^/"]+[/]?)"#is', $stripped_file, $matches);
  5.  
  6. $unikat = array_unique($matches[1]);
  7.  
  8. foreach ($unikat as $link)
  9. {
  10. for ($i = 0; $i < count($link); $i++)
  11. {
  12. echo $link[$i] . '<br />';
  13. }
  14. }
  15. ?>


Wyświetlają mi się tylko h, a jak zmienie w 6 linijce na $matches to pojawiają mi się tylko te 'linki' z czystego preg_match
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 27.12.2025 - 05:05