Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Wycięcie wszystkich czterocyfrowych liczb ze stringa
mefistofeles
post
Post #1





Grupa: Zarejestrowani
Postów: 255
Pomógł: 0
Dołączył: 23.06.2009

Ostrzeżenie: (10%)
X----


  1. $string = 'April 15, 2003';
  2. $pattern = '/([0-9]){4}/';
  3. $replacement = 'rok';
  4.  
  5. preg_replace ( $pattern , $replacement , $string);
  6. echo $string;


Chciałbym zamienić '2003' na 'rok', ale coś z moim wyrażeniem jest nie tak.

Ten post edytował mefistofeles 6.02.2010, 13:42:18
Go to the top of the page
+Quote Post
ayeo
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 1 202
Pomógł: 117
Dołączył: 13.04.2007
Skąd: 127.0.0.1

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


Witam!

  1. $string = 'April 15, 2003';
  2. $pattern = '#[0-9]{4}#';
  3. $replacement = 'rok';
  4.  
  5. echo preg_replace( $pattern , $replacement , $string);

Pozdrawiam!
Go to the top of the page
+Quote Post
mefistofeles
post
Post #3





Grupa: Zarejestrowani
Postów: 255
Pomógł: 0
Dołączył: 23.06.2009

Ostrzeżenie: (10%)
X----


Dzięki !

Ten post edytował mefistofeles 6.02.2010, 14:11:58
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: 22.08.2025 - 22:41