Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Usuwanie z tekstu
robak142
post
Post #1





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 17.03.2012

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


Witam,
Na mojej witrynie mam zainstalowane coś na kształt pluginu, dzięki któremu w tekście mogę prezentować zdjęcia z galerii, wpisując w tekście {galery XXX left} lub {galery XXX right}.
Gdzie XXX to numer id zdjęcia z tabeli bazy danych galerii, left lub right odpowiada za opływanie tekstu.
Sekwencje czasami pojawiają się pojedynczo, a czasami w grupach.
Przykład:
--------------------------
{galery XXX left}Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

{galery XXX right}{galery XXX right}{galery XXX right}{galery XXX right}It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
{galery XXX left}{galery XXX left}
------------------------
Dla co niektórych odsłon chciałbym wycinać w/w w php. Oczekiwanym efektem oczywiście jest:

-----------------------
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
-----------------------
Proszę o pomoc i z góry dziękuję.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 8)
Turson
post
Post #2





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

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


  1. $string = preg_replace("/{(.*)}/i", "", $string);
Go to the top of the page
+Quote Post
robak142
post
Post #3





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 17.03.2012

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


Cytat(Turson @ 28.01.2014, 12:12:59 ) *
  1. $string = preg_replace("/{(.*)}/i", "", $string);

Dziękuję,
Ten skrypt wytnie wszystko co jest pomiędzy nawiasami klamrowymi wraz z nimi. Mam jeszcze inne pluginy działające w podobny sposób. Chciałbym, aby wycinał tylko ten konkretny {galery xxx left} lub {galery xxx right}


Ten post edytował robak142 28.01.2014, 14:18:13
Go to the top of the page
+Quote Post
Turson
post
Post #4





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

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


  1. $string = preg_replace("/{galery \w right}/", "", $string);
  2. $string = preg_replace("/{galery \w left}/", "", $string);
Go to the top of the page
+Quote Post
robak142
post
Post #5





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 17.03.2012

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


Nie chcę nadużywać Twojego czasu i wiedzy, ale ten kod w ogóle na to nie działa. Jakieś inne pomysły?
Pozdrawiam
Cytat(Turson @ 28.01.2014, 15:02:33 ) *
  1. $string = preg_replace("/{galery \w right}/", "", $string);
  2. $string = preg_replace("/{galery \w left}/", "", $string);

Go to the top of the page
+Quote Post
Turson
post
Post #6





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

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


Działa

  1. $string = "{galery 1 left}Lorem Ipsum is simply dummy text {galery cos tam} of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
  2.  
  3. {galery 2 right}{galery 1 right}{galery 1 right}{galery 1 right}It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
  4. {galery 1 left}{galery 1 left}";
  5. $string = preg_replace("/{galery \w right}/", "", $string);
  6. $string = preg_replace("/{galery \w left}/", "", $string);
  7. echo $string;
Go to the top of the page
+Quote Post
--robak142--
post
Post #7





Goście







Cytat(Turson @ 28.01.2014, 15:33:57 ) *
Działa

  1. $string = "{galery 1 left}Lorem Ipsum is simply dummy text {galery cos tam} of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
  2.  
  3. {galery 2 right}{galery 1 right}{galery 1 right}{galery 1 right}It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
  4. {galery 1 left}{galery 1 left}";
  5. $string = preg_replace("/{galery \w right}/", "", $string);
  6. $string = preg_replace("/{galery \w left}/", "", $string);
  7. echo $string;


Działa tylko w przypadku jeżeli wartość liczbowa jest w przedziale 0<=XXX<=9. Czyli w poniższym przykładzie nie zadziała. A to przykład z życia wzięty
  1. $string = "{galery 1532 left}Lorem Ipsum is simply dummy text {galery cos tam} of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.{galery 2322 right}{galery 1421 right}";
  2. $string = preg_replace("/{galery \w right}/", "", $string);
  3. $string = preg_replace("/{galery \w left}/", "", $string);
  4. echo $string;

Wciąż nie ustaję w nadziei, że mi pomożesz. Pozdrawiam.
Go to the top of the page
+Quote Post
Turson
post
Post #8





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

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


  1. $string = "{galery 1 left}{galery 1532 left}Lorem Ipsum is simply dummy text {galery cos tam} of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.{galery 2322 right}{galery 1421 right}";
  2. $string = preg_replace("/{galery \d* right}/", "", $string);
  3. $string = preg_replace("/{galery \d* left}/", "", $string);
  4. echo $string;
Go to the top of the page
+Quote Post
--robak142--
post
Post #9





Goście







Działa perfekcyjnie. Dziękuję za pomoc i poświęcony czas.
Go to the top of the page
+Quote Post

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: 7.10.2025 - 09:12