Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Reskalizacja zdjęć w znacznikach IMG, !!! NA GWAŁT POTRZEBNA FUNKCJA
The Night Shadow
post
Post #1





Grupa: Zarejestrowani
Postów: 495
Pomógł: 2
Dołączył: 5.02.2006
Skąd: Wrocław

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


Gubię się w wyrażeniach regularnych. Mam ciąg tego typu:

<img width="233" height="175" alt="" src="adresik_pnrazka"/>

Potrzerbuję funkcji używającej wyrażeń regularnych, która zamieni mi to na to:

<img width="233" height="175" alt="" src="res.php?width=175&height=175&adres=adresik_pnrazka"/>

Potzrebne totalnie na wczoraj
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
webdice
post
Post #2


Developer


Grupa: Moderatorzy
Postów: 3 045
Pomógł: 290
Dołączył: 20.01.2007




Coś takiego?

  1. <?php
  2.  
  3. $str = '<img width="233" height="175" alt="" src="adresik_pnrazka"/>';
  4. $str2 = '<img style="width: 500px; height: 233px" src="adresik_pnrazka" alt="" width="500" height="100" />';
  5.  
  6. if (preg_match ('# style=#', $str))
  7. {
  8. print preg_replace ('#<img style="width: ([0-9]+)px; height: ([0-9]+)px" src="([^"]+)" alt="" width="500" height="100" />#', '<img width="$2" height="$2" alt="" src="res.php?width=$2&height=$2&adres=$3"/>', $str)
  9. }
  10. else
  11. {
  12. print preg_replace ('#<img width="([0-9]+)" height="([0-9]+)" alt="" src="([^"]+)"/>#', '<img width="$2" height="$2" alt="" src="res.php?width=$2&height=$2&adres=$3"/>', $str);
  13. }
  14.  
  15. ?>


EDIT: Znowu ten sam błąd zrobiłem, poprawiłem w kodzie.

Ten post edytował webdicepl 31.01.2008, 18:51:56
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: 13.10.2025 - 00:36