Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Wyciagniecie adresow obrazow, z kodu html
ikioloak
post 22.11.2005, 11:43:45
Post #1





Grupa: Zarejestrowani
Postów: 416
Pomógł: 0
Dołączył: 8.01.2004

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


Napisałem funckje do wyciagania adresow obrazow ze strony htm objetych w tagach <img src=""> oraz w <... background="" >
  1. <?php
  2.  
  3. function getImages($string)
  4. {
  5. $string=substr($string,strpos($string,'<body'));
  6. $pieces=explode(' ',$string);
  7. foreach ($pieces as $val)
  8. {
  9. $pos = strpos($val,'src="');
  10.  
  11. if ($pos === 0)
  12. {
  13.  
  14. $temp=substr(trim($val),5);
  15.  
  16. $temp=substr($temp,0,strlen($temp)-1);
  17. if ((strpos($temp,'.jpg'))||(strpos($temp,'.gif'))||(strpos($temp,'.png')))
  18. $return[]=$temp;
  19. }
  20.  
  21. $pos = strpos($val,'background="');
  22.  
  23. if ($pos === 0)
  24. {
  25.  
  26. $temp=substr(trim($val),12);
  27.  
  28. $temp=substr($temp,0,strlen($temp)-1);
  29. if ((strpos($temp,'.jpg'))||(strpos($temp,'.gif'))||(strpos($temp,'.png')))
  30. $return[]=$temp;
  31. }
  32. }
  33. return $return;
  34. }
  35.  
  36. ?>


Funkcja dziala ale mysle ze mozna rozwiazac to wyrazeniami regularnymi - co moja mocna strona nie jest. Jesli ma ktos pomysl, lub dojzy blad w funkcji to prosze o komentarz.
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 Wersja Lo-Fi Aktualny czas: 14.08.2025 - 06:19