Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] wyrażenia regularne
peter13135
post
Post #1





Grupa: Zarejestrowani
Postów: 1 447
Pomógł: 191
Dołączył: 26.03.2008

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


mam taki string

  1. $string= 'dsfdsff [cos]lala[/cos] bleble [/cos]blabla[/cos] dsdfsdsffds';


w jaki sposób mogę za pomocą bbcode "wyjąć" teksty (podciągi?) z tego stringu spomiędzy tagów [cos] i [/cos]

zrobiłem takie coś
  1. preg_match_all('/\[cos\][[:print:]\s]*\[\/cos\]/', $string, $out);


ale to zwraca mi tablicę z jednym elementem - '[cos]lala[/cos] bleble [/cos]blabla[/cos]'
w jaki sposób mogę osiągnąć tablice z dwoma elementami : '[cos]lala[/cos]' oraz '[/cos]blabla[/cos]' (IMG:style_emoticons/default/questionmark.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
r4xz
post
Post #2





Grupa: Zarejestrowani
Postów: 673
Pomógł: 106
Dołączył: 31.12.2008

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


  1. <?php
  2.  
  3. $str = 'dsfdsff [cos]lala[/cos] bleble [cos]blabla[/cos] dsdfsdsffds';
  4. preg_match_all('/\[cos\](.*?)\[\/cos\]/', $str, $out);
  5. print_r($out);
  6.  
  7. ?>
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: 11.10.2025 - 22:26