Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> częste wykorzystanie funkcji
kicaj
post
Post #1





Grupa: Zarejestrowani
Postów: 1 640
Pomógł: 28
Dołączył: 13.02.2003
Skąd: Międzyrzecz/Poznań

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


Funkcja:
  1. <?php
  2. function f( $strTagName, $strTagNewValue )
  3. {
  4. $resNewFile = preg_replace( '|<'. $strTagName .'>(.*)</'. $strTagName .'>|isU', '<'. $strTagName .'>'. $strTagNewValue .'</'. $strTagName .'>', $this -> resFileContent );
  5.  
  6. $resOldFile = fopen( $this -> resFileOpen, 'w+' );
  7. fwrite( $resOldFile, $resNewFile );
  8. fclose( $resOldFile );
  9. }
  10. ?>

Wykorzystuje ja w taki sposob:
  1. <?php
  2. f( 'a', '1' );
  3. f( 'b', '2' );
  4. f( 'c', '3' );
  5. f( 'd', '4' );
  6. ?>

I zamienia tylko ostatni fragment!
Dlaczego nie zamienia wszystkich?
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: 23.08.2025 - 17:40