Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Kolejność działania funkcji.
cykcykacz
post
Post #1





Grupa: Zarejestrowani
Postów: 550
Pomógł: 9
Dołączył: 29.05.2009
Skąd: Ostrów Wielkopolski

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


Hej,
mam kłopot jeśli zrobię taką operację na stringu:
  1. $string = "<strong><em>do</em></strong><em>wynajęcia</em> lokal handlowy - Ostrów ul. Kolejowa xx - xxx-xxx-xxx";
  2. $new_string = preg_replace('/\<em>(.*?)\<\/em>/e', 'strtoupper("$0")', $string);
  3.  
  4. $result = str_replace(
  5. array('<strong>', '</strong>'),
  6. array('<b>', '<$>'),
  7. $new_string
  8. );
  9.  
  10. echo $result;


To funkcja str_replace nie chce podmienić znaków.

Na tomiast jeżeli zrobię str_replace przed "preg_replace" działa.

Jak to ustawić żeby działało dobrze?

Ps: Potrzebuje takiej kolejności działań!

Ten post edytował cykcykacz 28.06.2013, 07:55:04
Go to the top of the page
+Quote Post
styryl
post
Post #2





Grupa: Zarejestrowani
Postów: 223
Pomógł: 27
Dołączył: 16.04.2008
Skąd: Bakutilu

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


Puściłem u siebie i działa bez problemu, zamienia <strong> na <b> i </strong> na <$>
Go to the top of the page
+Quote Post
nospor
post
Post #3





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Dokładnie, mi też działa (IMG:style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
cykcykacz
post
Post #4





Grupa: Zarejestrowani
Postów: 550
Pomógł: 9
Dołączył: 29.05.2009
Skąd: Ostrów Wielkopolski

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


Kurcze, sory ale u mnie w domu i teraz na innym komputerze nie widziałem efektu teraz jest dobrze.

Tylko wyskoczył jeszcze jeden problem korzystam z funkcji strtoupper i niechce mi zamienić małego ę na duże Ę.
Jak sobie z tym poradzić?

  1. $string = "<strong><em>do</em></strong><em>wynajęcia</em> lokal handlowy - Ostrów ul. Kolejowa xx - xxx-xxx-xxx";
  2. $new_string = preg_replace('/\<em>(.*?)\<\/em>/e', 'strtoupper("$0")', $string);

Go to the top of the page
+Quote Post
nospor
post
Post #5





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Przy zalozeniu ze to jest utf8 skorzystaj z funkcji z rodziny mb_
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: 23.08.2025 - 12:10