Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Regular Expressions #2, Wylapywanie blokow.
Kirtan Loor
post
Post #1





Grupa: Zarejestrowani
Postów: 44
Pomógł: 0
Dołączył: 22.10.2004
Skąd: Płock

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


Witam.
Mam swoisty klopoty z wyjasnieniem mojego problemu, wiec zaczne od przykladu ;-)

mam plik tpl:
  1. <!-- BEGIN formularz -->
  2. <!-- BEGIN error_box -->
  3. <div style="text-align:center;font-weight:bold;">{ERROR_MSG}</div>
  4. <!-- END error_box -->
  5.  
  6. <form method="post">
  7. <p>Twoje imię (jeżeli masz dwa imiona, oddziel je spacją):<br />
  8. <input type="text" name="name" value="{V_NAME}" size="30" {C_NAME} /></p>
  9.  
  10. <p>Twoje nazwisko (jeżeli masz dwa nazwiska napisz je tak: N-N):<br />
  11. <input type="text" name="surname" value="{V_SURNAME}" size="30" {C_SURNAME}/></p>
  12.  
  13. <input type="hidden" name="{HIDDEN}" value="1" />
  14. <p><input type="submit" value="Zapisz" /></p>
  15. </form>
  16. <!-- END formularz -->


oraz plik php:
  1. <?php
  2. // $file - zawartosc pliku html.
  3.  
  4. preg_match_all("#<!-- BEGIN (.*?) -->(.*?)<!-- END (.*?) -->#si", $file, $matches);
  5.  
  6. ?>

Ten kod (wersja uproszczona), jak widac ma wylapywac mi kod html ktory znajduje sie w blokach. Moje pytanie, jak zrobic zeby wylapywal mi bloki o tych samych nazwach (a nie, jak w tym wypadku: zaczynal formularzem a konczyl error_boxem)?


--------------------
A Chartreux et à Célestins, A Mendiants et à Dévotes,
A musards et claquepatins, A servants et filles mignottes
Portants surcots et justes cottes,A cuidereaux d'amour transis,
Chaussant sans méhaing fauves bottes, Je crie à toutes gens mercis.
Go to the top of the page
+Quote Post
xblant
post
Post #2





Grupa: Zarejestrowani
Postów: 76
Pomógł: 0
Dołączył: 31.01.2006

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


sprobuj tak
  1. <?php
  2. preg_match_all("#<!-- BEGIN (.*?) -->(.*?)<!-- END 1 -->#si", $file, $matches);
  3. ?>


Ten post edytował xblant 27.06.2006, 20:11:22


--------------------
Go to the top of the page
+Quote Post
Kirtan Loor
post
Post #3





Grupa: Zarejestrowani
Postów: 44
Pomógł: 0
Dołączył: 22.10.2004
Skąd: Płock

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


Nope, nie dziala

Ktos ma jakis inny pomysl?


--------------------
A Chartreux et à Célestins, A Mendiants et à Dévotes,
A musards et claquepatins, A servants et filles mignottes
Portants surcots et justes cottes,A cuidereaux d'amour transis,
Chaussant sans méhaing fauves bottes, Je crie à toutes gens mercis.
Go to the top of the page
+Quote Post
tiraeth
post
Post #4





Grupa: Przyjaciele php.pl
Postów: 1 789
Pomógł: 41
Dołączył: 30.10.2003
Skąd: Wrocław

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


Trzymaj w tablicy nazwy bloków i potem sobie odpowiednio wyłapuj foreach'em smile.gif
Go to the top of the page
+Quote Post
Kirtan Loor
post
Post #5





Grupa: Zarejestrowani
Postów: 44
Pomógł: 0
Dołączył: 22.10.2004
Skąd: Płock

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


Ech, tak aktualnie robie;-) Ale myslalem ze moze mozna to w regular expr. zalatwic.


--------------------
A Chartreux et à Célestins, A Mendiants et à Dévotes,
A musards et claquepatins, A servants et filles mignottes
Portants surcots et justes cottes,A cuidereaux d'amour transis,
Chaussant sans méhaing fauves bottes, Je crie à toutes gens mercis.
Go to the top of the page
+Quote Post

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: 19.08.2025 - 13:06